Jquery gets the value method of the currently clicked object

  • 2020-03-30 02:11:49
  • OfStack

Example: gets the value of li in ul

First, in HTML we set the value for each li
 
<ul> 
<li value=" hello "></li> 
<li value="hello"></li> 
<li value="=-="></li> 
</ul> 

Then get the corresponding value according to the click event through jquery
 
$(document).ready(function(){ 
$("li").click(function{ 
alert($(this).val()); 
}); 
}); 

Related articles: