jQueru中addClass和removeClass的使用

<body>
	<img src = "" alt = ""/>
	<img src = "" alt = ""/>
	<img src = "" alt = ""/>
	<img src = "" alt = ""/>
</body>
<script src = " ../ ../ js /jquery-3.1.1.min.js "></script>
<script>
	$("img").addClass(function(index){
		return "img" + (index + 1);
	});								//給每個img插入不同的class屬性
	
	$("img").removeClass(function(index){
		if (index % 2){
			return "img" + (index + 1);		//隔行移除class
		}
	});
</script>
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章