这篇文章主要介绍了jquery中each方法使用及常用选择器都有哪些,需要的朋友,可以参考下
<head>
<title></title>
<script src="jquery-1.4.2.js" type="text/javascript"></script>
<script type="text/javascript">
$(function() {
//alert($("p").text());
//对数组元素使用匿名函数进行逐个处理。
$("p").each(function(key, value) {
//alert(key+value);
// alert($(value).text());
alert(this.innerHTML);
});
//this表示当前遍历的dom元素
$("p").each(function() {
alert($(this).text());
});
});
</script>
</head>
<body>
<p id="testDom">11111</p>
<p>2222</p>
<p>33333</p><div class="aritcle_card flexRow">
<div class="artcardd flexRow">
<a class="aritcle_card_img" href="/ai/1244" title="Dreamina"><img
src="https://img.php.cn/upload/ai_manual/000/000/000/175680139826778.jpg" alt="Dreamina" onerror="this.onerror='';this.src='/static/lhimages/moren/morentu.png'" ></a>
<div class="aritcle_card_info flexColumn">
<a href="/ai/1244" title="Dreamina">Dreamina</a>
<p>字节跳动推出的AI绘画工具,用简单的文案创作精美的图片</p>
</div>
<a href="/ai/1244" title="Dreamina" class="aritcle_card_btn flexRow flexcenter"><b></b><span>下载</span> </a>
</div>
</div>
</body>常用选择器:
1.类:$(".error").
2.id:$("#daLong").
3.标签:$("p").
4.属性:$("p[name=apple]").
5.表单:$("input:checked").









