计算ID名称在html中出现的次数,并计算回显总数 [英] Count the number of times an id name appears in html and echo total

查看:77
本文介绍了计算ID名称在html中出现的次数,并计算回显总数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好.
此代码块为在线商店中的单个项目创建缩略图.如果将商品添加到商店,此代码将重复.项目数量可以是1到100之间的任何值,具体取决于要出售的项目数量.
我想做的是计算id ="thumb"在html中出现的次数,然后回显这个数量,例如-``Items of Number:#''

Hello folks.
This block of code creates a thumbnail for an individual item in an online shop. This code is duplicated if an item is added to the shop. The item amount could be anything from 1 to 100, depending on how many items are for sale.
What I would like to do is count the amount of times the id="thumb" appears in the html, then echo this amount, for example - ''Number of items: # ''

<div id="thumb">
<div id="thumbbackground">
<a href="../screen-printing/map.php">
<div id="image" class="a"><img src="../screen-printing/thumbnails/map.jpg" width="170" height="170"/></div>
</a>
<div id="prelo1" class="p"></div>
</div>
<div id="thumbname"><p class="desc8">Map</p></div>
</div>

推荐答案


text = ' < div id ="thumb">< img/></div> < div id ="thumb">< img/></div>';
text = '<div id="thumb"><img /></div><div id="thumb"><img /></div>';


countMe = ' ;
countMe = 'id="thumb"';


这篇关于计算ID名称在html中出现的次数,并计算回显总数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆