<head>
<style>
#box {
width: 300px;
height: 60px;
background: green;
color: black;
font-size: 20px;
}
.images {
margin-top: 20px;
}
</style>
</head>
<body>
<div id="box">
<p style="padding: 20px;">Images Count:</p>
</div>
<div class="images">
<img src="img001.jpg">
<img src="img002.jpg">
<img src="img003.jpg">
<img src="img004.jpg">
<img src="img005.jpg">
<img src="img006.jpg">
</div>
请帮我查看显示计数的代码,计数显示需要进行计数。
答案 0 :(得分:0)
您可以尝试以下代码
$(document).ready(function(){
console.log("Images count="+ $(".images").find("img").length)
$("#imgcount").text( $(".images").find("img").length)
});
&#13;
<div id="box">
<script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.2.1.min.js">
</script>
<p style="padding: 20px;">Images Count:</p>
</div>
<div class="images">
<img src="img001.jpg">
<img src="img002.jpg">
<img src="img003.jpg">
<img src="img004.jpg">
<img src="img005.jpg">
<img src="img006.jpg">
</div>
Total No. of Images in page are <label id="imgcount">
&#13;