标签:div style head func margin pre query OLE arp
在div中,有一类div标签,class值为div1,数量不等,有多个。我需要在点击某一个标签的时候实时获取该标签在这类标签中的索引值,以便进行其他操作。
<!DOCTYPE html>
<html>
<head>
<style>
div { width:60px; height:60px; margin:10px; float:left;
border:2px solid blue; }
.blue { background:blue; }
</style>
<script type="text/javascript" src="/jquery/jquery.js"></script>
</head>
<body>
<div class="div1"></div>
<div class="div1"></div>
<div class="div1"></div>
<div class="div1"></div>
<div class="div1"></div>
<div class="div1"></div>
<script>
$(".div1").click(function(){
var index=$(".div1").index($(this));
console.log(index);
alert(index);
})
</script>
</body>
</html>
点击某一个标签的时候实时获取该标签在这类标签中的索引值,以便进行其他操作。
标签:div style head func margin pre query OLE arp
原文地址:https://www.cnblogs.com/whqbk/p/13445309.html