如何使用JAVASCRIPT检查HTML中特定控件的出现次数 [英] How to check number of Occurrence of a particular Control in HTML using JAVASCRIPT

查看:58
本文介绍了如何使用JAVASCRIPT检查HTML中特定控件的出现次数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在页面上有listview控件,我在其中给出了复选框(在< ItemTemplate>中)以选择任意行.....





作为列表视图加载复选框,每行根据LISTVIEW中可用的数据生成.....



listview中的Checkbox ID似乎

for first row id of checkbox is ListView1_chkbx1_0

for second row id of checkbox is ListView1_chkbx1_1

for third row id of checkbox复选框是ListView1_chkbx1_2



我希望你的帮助能够找到页面上加载的页面上有多少个复选框



OR

你能告诉我怎么能找不到。列表视图中存在的行,因为没有。行和没有。复选框将是相同的:)





提前thnx:)

i HAVE listview control on page in which i have given checkbox(in <ItemTemplate>) to select any row.....


as listview is loaded checkbox for each row gets generated based on data available in LISTVIEW.....

ID's of Checkbox in listview appears like
for First row id of checkbox is ListView1_chkbx1_0
for Second row id of checkbox is ListView1_chkbx1_1
for Third row id of checkbox is ListView1_chkbx1_2

I want your HELP to FIND out HOW MANY CHECKBOXES ARE PRESENT IN PAGE AFTER PAGE GETS LOADED

OR
U can tell me how can I find no. of rows present in listview because no. of rows and no. of checkboxes will be the same :)


Thnx in advance :)

推荐答案

在客户端你可以实现以下目标



In client side you can achieve this as below


('#yourList li')。size()// li - 是与你的复选框号码相同的列表项目
('#yourList li').size() // li - is the list item which is same as your number of checkbox





希望这有助于



Hope this helps


这是一个使用jquery的基于正则表达式的最快方法



var totalElements =
This is a regex based fastest approach using jquery

var totalElements =


这篇关于如何使用JAVASCRIPT检查HTML中特定控件的出现次数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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