我有这个简单的 HTML 代码:
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<title>Demo</title>
</head>
<body>
<script src="jquery.js"></script>
<script src="prova.js"></script>
<div class="altro"><a href=#>Div 1</a></div>
<div class="ann"><a href=#>Div 2</a></div>
<div class="ann"><a href=#>Div 3</a></div>
</body>
</html>
我想使用 JQuery 脚本提取类“ann”的第二个 div“Div 2”的内容。我试过:
var str = $( ".ann" ).text();
但是它同时需要 Div 2 和 Div 3。我怎样才能只提取我想要的那个?
最佳答案
关于javascript - 使用 JQuery 从 div 类中提取文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20870795/