js gets the value of the li tag

http://blog.csdn.net/hgh19890130/article/details/8803630
First of all, you should note that the value attribute of the li tag only supports numeric types. That is, the serial number of the tag. So if you want to get the attributes in the li, you can Customize the attribute in the li tag yourself. Then get the value of the attribute through jquery's attr method
<ul>
    <li p="Course Design"><a href="javascript:;">Course Design</a></ li>
    <li p="School Year Paper"><a href="javascript:;">School Year Paper</a></li>
</ul>
$(function(){
    $("li").click( function(){
        alert($(this).attr("p"))
    });
});

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326948296&siteId=291194637