0
<html>
<head>
<title>List Manipulation</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("ul li").click(function(){
var s;// in this variable i want "list item 1"
window.alert(s);
});
});
</script>
</head>
<body>
<ul>
<li>list item 1</li>
</ul>
</body>
</html>
我已经写了一个简单的html代码,它有无序列表。当我点击这个列表中的元素时,我想要点击列表元素的内容。我在代码中评论过它。 我试图
使用jQuery获取列表数据
var s = this.text;//giving undefined value
var s = this.value ;// giving 0
变种S = $(本)的.text() –