Ngày đăng: 26/11/2018

Get ID element with Jquery


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Get ID Element With Jquery</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
</head>
<body>
<ul>
<li id="1"><a href="javascript:void(0)">Link 1</a></li>
<li id="2"><a href="javascript:void(0)">Link 2</a></li>
<li id="3"><a href="javascript:void(0)">Link 3</a></li>
</ul>
</body>
</html>
<script>
$("li").click(function(){
	var id = $(this).attr("id");
	alert(id);
});
</script>