Monday 3 September 2018

PHP / Jquery: Using the value of the clicked element in a function

I have an element of label class

<li><a><span class='label'>$element</span></a></li>

and I want to be able to run loadStuff onclick. How do I get the value of the clicked element to pass in like:
$(".label").click(loadStuff(valueOfClickedElement));


When you say value, I assume you meant text of the span..
If so, then try below,
$(".label").click(function () {
   loadStuff($(this).text());
});

0 comments:

Post a Comment