jquery获取当前点击的对象元素(实现代码)
<script type="text/javascript" src="script/jquery-1.8.3.js"></script>
</head>
<body>
<p>段落1</p>
<p>段落2</p>
<p>段落3</p>
<p>段落4</p>
<div class="aritcle_card">
<a class="aritcle_card_img" href="/ai/1636">
<img src="https://img.php.cn/upload/ai_manual/000/969/633/68b6d8421727c371.png" alt="letterdrop">
</a>
<div class="aritcle_card_info">
<a href="/ai/1636">letterdrop</a>
<p>B2B内容营销自动化平台,从创意到产生潜在客户的内容的最佳实践和工具。</p>
<div class="">
<img src="/static/images/card_xiazai.png" alt="letterdrop">
<span>49</span>
</div>
</div>
<a href="/ai/1636" class="aritcle_card_btn">
<span>查看详情</span>
<img src="/static/images/cardxiayige-3.png" alt="letterdrop">
</a>
</div>
<p>段落5</p>
<script type="text/javascript">
//获取当前点击的对象
$('p').click(
function(){
//this表示当前被点击元素,但是此时我们当做dom对象
//window.alert(this.innerHTML);
//$(this) 表示当前被点击元素,但是此时我们当做jquery对象
window.alert($(this).html());
//window.alert('ok');
});
</script>
</body> 以上这篇jQuery获取当前点击的对象元素(实现代码)就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持本站。
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号