inforakesha

A fine WordPress.com site

Jquery Making call only first time OnClick event

Leave a comment

 

 

change

$("a.test").click(function() {

to

$("a.test").live('click', function() {

The reason why only the first element is working is because at the time the click event is attached, there is only one <a> element on the page. You need to explicitly add the click event handler to every anchor that is created, or use live events instead. Read more about live event handlers.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s