jQuery常用方法

jQuery是javascript的一个常用框架,包含很多很方便的方法:

<script>
$document.ready(function(){
}
</script>

常用方法:.addClass .removeClass .prop .html .clone .parent .children .appendTo :nth-child()
常用属性:animated bounce text-primary fadeout hinge

<script>
$document.ready(function){
$(".button").addClass("animated");
$("#target1").clone().appendTo("left-well");
}

示例:获取 class 为target且索引为奇数的所有元素,并给他们添加 class。

$(".target:odd").addClass("animated shake");

记住,jQuery 里的索引是从 0 开始的,也就是说::odd 选择第 2、4、6 个元素,因为 target#2(索引为 1),target#4(索引为 3),target6(索引为 5。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容