Home >Web Front-end >JS Tutorial >jquery gets the value method of the currently clicked object_jquery

jquery gets the value method of the currently clicked object_jquery

WBOY
WBOYOriginal
2016-05-16 16:57:511510browse

Example: Get the value of li in ul

First, in html we need to set the value for each li

Copy code The code is as follows:







Then click through jquery The event gets the corresponding value
Copy the code The code is as follows:

$(document).ready( function(){
$("li").click(function{
alert($(this).val());
});
});
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn