Can you get the id
attribute of a html tag using jQuery or without?
For example:
<ul id="todo" />
How can I get the id
, without using jQuery("#todo")
?
Is there a way for that? Will attr()
work?
You can use attr('id')
in jQuery or the id
property (or getAttribute('id')
) on the native DOM element.
The way I see it, you most probably need to attach a selector class to the ul so that you can use it to get the id:
<ul id="todo" class="todoclassname" />
then, you can get the id by doing:
$(".todoclassname").attr("id");
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