I have several li
element in page:
<li value="a">a</li>
<li value="b">b</li>
<li value="c">c</li>
<li value="d">d</li>
the I want get the value property when hover on it:
$(function () {
$('li').live('mouseover', function () {
console.log($(this).prop('value'));
})
});
but the result is always 0
,then I try the attr()
method, it still can not work ,how can I solve this problem?
li
elements do not have avalue
property.For storing your own meta-data against an element you should use HTML5
data-*
attributes:Then use the jquery
.data()
method to retrieve them: