So i have a very simple html:
<ul>
<li value="test">test</li>
</ul>
And this jquery script
alert($("li").attr("value"));
It should return test
but it returns 0, why is this happening?
If you want to return the text inside the li tag then:
alert($("li").text());
You can't use the 'value' attribute(The 'value' attribute in the li tag can only be numeric). Rename it to data-value:
alert($("li").attr("data-value"));
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