954,561 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

click function not working

why isn't this working?

$('body').find(".overcolor").click(function(){
	alert("hi");
});
Virangya
Junior Poster
122 posts since Apr 2010
Reputation Points: 10
Solved Threads: 0
 

just out of curiousity, why not do this:

$('.overcolor').click(function(){
	alert("hi");
});


However if you are adding elements dynamically, this won't work, use this instead:

$('.overcolor').live('click', function(){
	alert("hi");
});
stbuchok
Master Poster
730 posts since May 2011
Reputation Points: 120
Solved Threads: 93
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: