I have ul with a number of li inside. All li have an id "#category" but different classes (like ".tools", ".milk", ".apple").
Using jQuery. I do :
$("li#category").click(function(){ some_other_thing ( .... )});
now i have to put a li's class "name" — (a string indeed) inside the some_other_thing() function instead of ....
How it can be done?
$(this).attr('class')
Beware that id
must be unique! You're suggesting that each li
element has the same id
. You might want to replace it with a class
, e.g.:
<ul>
<li class="category tools" />
<li class="category milk" />
</ul>
Then select with:
$('li.category').click(function(){});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With