美文网首页
jQuery常用方法

jQuery常用方法

作者: 金没日成 | 来源:发表于2016-12-21 12:52 被阅读9次

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。

相关文章

网友评论

      本文标题:jQuery常用方法

      本文链接:https://www.haomeiwen.com/subject/ngrqvttx.html