怎么样获得页面内所有“id号以cat10开头,以000结尾”的对象? “便利判断”是啥意思?好像google不到呀 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 get所有的element,然后循环正则判断id,转入另一个集合 呵呵,简单实现,启发一下,哈<html> <head> <title> New Document </title> </head> <body><textarea id="ttaOne" rows="5" cols="30"></textarea> <textarea id="ttaTwo" rows="5" cols="30"></textarea> <textarea id="cat10ttaTwo000" rows="5" cols="30"></textarea> </body><script language="JavaScript"><!--var colAll = document.getElementsByTagName("*");var re = /^cat10(\w)*000$/gi;for (var i=0; i<colAll.length; i++){ if (colAll[i].id) { if (colAll[i].id.match(re)) { alert(colAll[i].id + " have been found. Do what you want!"); } }}//--></script></html> <input id="cat1011000"><input id="a" onchange="return check(this.value)"><script>o = document.all;p = /^cat10.*000$/;for(c=0;c<o.length;c++){ if(p.test(o[c].id)) alert(o[c].id);}</script> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312" /><title>取对象</title><script type="text/javascript">var search = { array : [], parse : function (o) { var wc = this, a = o.childNodes, i; if (a) { for (i = 0 ; i < a.length ; i ++) { if (a[i].nodeType == 1) { if (/^cat10.*000$/.test(a[i].id)) wc.array[wc.array.length] = a[i].id; wc.parse(a[i]); } } } }};window.onload = function () { search.parse(document.body); alert(search.array.join("\n"));};</script></head><body><div id="cat10_01_000"> <div id="cat10_05_000"> <div id="cat10_06_000"> <div id="cat10_07_000"> <div id="cat10_08_000"> <div id="cat10_09_000"></div> </div> </div> </div> </div></div><div id="cat10_02_000"></div><div id="cat10_03_000"></div><div id="cat10_04_000"></div><div id="cat10000"></div><div id="cat1000"></div></body></html> 有没有带“文章版本”功能的富文本编辑器?或如何拓展现有功能实现? 求助:有关浏览器无法显示网页部分内容 js 兼容问题 求一段jquery loading代码? 麻烦哪位大虾解释下这段js是什么意思? 多个下拉框选中后弹出新窗口的问题 如何用JavaScript开发个UBB 关于js调用qq进程的问题 如何验证一个页面中的所有单选按纽(动态产生的)是否已点选? 各位高人,救命呀,我快崩溃了,关于frame~~~,分数不多了,见谅~~ 求一段控制左边框架的收缩代码 再发个问题,请求解决!解决后散分
<head>
<title> New Document </title>
</head> <body>
<textarea id="ttaOne" rows="5" cols="30"></textarea>
<textarea id="ttaTwo" rows="5" cols="30"></textarea>
<textarea id="cat10ttaTwo000" rows="5" cols="30"></textarea>
</body>
<script language="JavaScript">
<!--
var colAll = document.getElementsByTagName("*");var re = /^cat10(\w)*000$/gi;for (var i=0; i<colAll.length; i++)
{
if (colAll[i].id)
{
if (colAll[i].id.match(re))
{
alert(colAll[i].id + " have been found. Do what you want!");
}
}
}
//-->
</script>
</html>
<input id="a" onchange="return check(this.value)">
<script>
o = document.all;
p = /^cat10.*000$/;
for(c=0;c<o.length;c++)
{
if(p.test(o[c].id)) alert(o[c].id);
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>取对象</title>
<script type="text/javascript">
var search = {
array : [],
parse : function (o) {
var wc = this, a = o.childNodes, i;
if (a) {
for (i = 0 ; i < a.length ; i ++) {
if (a[i].nodeType == 1) {
if (/^cat10.*000$/.test(a[i].id)) wc.array[wc.array.length] = a[i].id;
wc.parse(a[i]);
}
}
}
}
};
window.onload = function () {
search.parse(document.body);
alert(search.array.join("\n"));
};
</script>
</head>
<body>
<div id="cat10_01_000">
<div id="cat10_05_000">
<div id="cat10_06_000">
<div id="cat10_07_000">
<div id="cat10_08_000">
<div id="cat10_09_000"></div>
</div>
</div>
</div>
</div>
</div>
<div id="cat10_02_000"></div>
<div id="cat10_03_000"></div>
<div id="cat10_04_000"></div>
<div id="cat10000"></div>
<div id="cat1000"></div>
</body>
</html>