Prototype实战教程----1.$$
2010-09-14 13:10:36 来源:WEB开发网<html>
<head>
<title>Test $$</title>
<script src="prototype.js"></script>
<script>
function test$$(){
/**//*
in case CSS is not your forte, the expression below says
'find all the INPUT elements that are inside
elements with class=field that are inside a DIV
with id equal to loginForm.'
*/
var f = $$('div#loginForm .field input');
var s = '';
for(var i=0; i<f.length; i++){
s += f[i].value + '/';
}
alert(s); // shows: "joedoe1/secret/"
//now passing more than one expression
f = $$('div#loginForm .field input', 'div#loginForm .fieldName');
s = '';
for(var i=0; i<f.length; i++){
s += ( f[i].value ? f[i].value : f[i].innerHTML ) + '/';
}
alert(s); //shows: "joedoe1/secret/User name:/Password:/"
var temp=$$('div#loginForm .field');
alert(temp.innerHTML);
}
function testtoColorPart()
{var num=new Number(50);
alert(num.toColorPart());
}
</script>
<div id='loginForm'>
<div class='field'>
<span class='fieldName'>User name:</span>
<input type='text' id='txtName' value='joedoe1'/>
</div>
<div class='field'>
<span class='fieldName'>Password:</span>
<input type='password' id='txtPass' value='secret' />
</div>
<input type='submit' value='login' />
</div>
<input type=button value='test $$()' onclick='test$$();' />
<input type=button value='testtoColorPart' onclick='testtoColorPart();' />
</body>
</html>
- ››实战:企业使用交换机VLAN路由配置
- ››实战案例分析:高质量软文对网站百度排名的影响
- ››实战经验浅谈网站搬家后的优化工作
- ››实战Active Directory站点部署与管理,Active Dir...
- ››实战操作主机角色转移,Active Directory系列之十...
- ››Prototype1.5.0 API 参考
- ››Prototype1.5 诡异错误一例
- ››Prototype : $() 的变化
- ››Prototype 的新函数 —— $$
- ››Prototype使用学习手册指南之dom.js
- ››Prototype使用学习手册指南之Selector.js
- ››Prototype使用学习手册指南之form.js
更多精彩
赞助商链接