Quantcast
Channel: WordPress.org Forums » All Topics
Viewing all articles
Browse latest Browse all 67836

Using THIS jQuery selector in a onclickevent function

$
0
0

Replies: 0

Hi,

I have been using jQuery selector extensivly in my project but the THIS selector is causing me problems. The answer must be straightforward but… not for me !

I have a button inside a personnel class fieldset. This fieldset is duplicated 20 times with the same button in each one. The button calls the resetpersonnel() function here below. I would like the indexpersonneltobedeleted variable to give the index of the personnel fieldset that has been clicked.

It seems that I’m not using the THIS selector the right way.

I appreciate if you can help me with this.


function resetpersonnel()
{
var indexpersonneltobedeleted = jQuery('.personnel').index(jQuery(this).closest('.personnel'));

...
}

Best Regards,
Skander


Viewing all articles
Browse latest Browse all 67836

Trending Articles