-1

If I attach to onclick in an anchor tag for example, should I be able to see this in Firebug after the DOM has loaded?

The onclick is not firing and I'm trying to figure out what is wrong.

$("#myelementid").click(function() {
    alert('test'); 
    return false;
});

I've also tried .onclick(...)

4thSpace
  • 43,672
  • 97
  • 296
  • 475

1 Answers1

2

http://jsfiddle.net/yUTVe/

I think you'll have to dig a little deeper, as you could have open brackets somewhere. Your code is completely fine, so unless you are dynamically creating that element (and thus, the JQuery doesn't work for it), there must be a syntax error somewhere else.

$("#myelementid").click(function() {
alert('test'); 
return false;
});
RCNeil
  • 8,581
  • 12
  • 43
  • 61
  • I guess something is conflicting somewhere. To answer my OP, I checked your code on jsfiddle. The onclick doesn't show up in the DOM. – 4thSpace May 06 '13 at 20:41
  • Not sure why stackoverflow doesn't let you me up vote your answer. Says I can't vote for my own post. – 4thSpace May 06 '13 at 20:42
  • No worries, hope you find what's causing your issue. Good luck. – RCNeil May 07 '13 at 00:29