have和has的用法口訣,hasClass用法

 2023-12-25 阅读 32 评论 0

摘要:hasClass:檢查當前元素是否含有某個特定的類,如果有,就返回true。 下載本地,做外部鏈接:<script type="text/javascript" src="jquery-1.7.2.min.js"></script> HTML結構: <div class="pr

hasClass:檢查當前元素是否含有某個特定的類,如果有,就返回true。

下載本地,做外部鏈接:<script type="text/javascript" src="jquery-1.7.2.min.js"></script>

HTML結構:

 <div class="protected"></div><div class="er"></div>

have和has的用法口訣。CSS代碼:

?//這里注意div容器要設置絕對定位!
.protected
{ width:100px; height:100px; background:#ff0; position:absolute; z-index:50; }
.er { width:100px; height:100px; background:#f00; position:absolute; z-index:50; top:200px; }

jQuery代碼:

 <script type="text/javascript">$(document).ready(function(){$("div").click(function(){if ($(this).hasClass("protected")){$(this).animate({ left: -10 }).animate({ left: 30 }).animate({ left: -10 }).animate({ left: 30 }).animate({ left: 0 });}});})</script>

?

?

have has 的用法。?

轉載于:https://www.cnblogs.com/pqw1991/archive/2012/08/30/2663400.html

版权声明:本站所有资料均为网友推荐收集整理而来,仅供学习和研究交流使用。

原文链接:https://808629.com/196803.html

发表评论:

本站为非赢利网站,部分文章来源或改编自互联网及其他公众平台,主要目的在于分享信息,版权归原作者所有,内容仅供读者参考,如有侵权请联系我们删除!

Copyright © 2022 86后生记录生活 Inc. 保留所有权利。

底部版权信息