My div has no id .
can i call a jquery function on click of that div
div identified by class used in div.
<div class="divclass">
how can i call
$('.divclass').click(
???
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
To assign a
clickhandler, you can do this:…or this, which is the same thing:
Here’s an example: http://jsfiddle.net/MAKHh/
EDIT:
As noted by @mcgrailm, there’s another means of firing code on the click of an element called
.live(). As well as a related one called.delegate().With
live(), the handler will fire regardless of when the element is added to the page.Or with
.delegate()you call it agains a container, and elements added to that container at any time will fire the handler.Or if you wanted to
.trigger()a click event, do this:Or this:
You can also call the handler without triggering the event.