js 利用className得到对象的实现代码

网络编程 发布日期:2024/10/17 浏览次数:1

正在浏览:js 利用className得到对象的实现代码
下面代码直接copy 就能用l
复制代码 代码如下:
<!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=utf-8"/>
<style type="text/css">
/* Reset style */
* { margin:0; padding:0;}
.input_ocurrent { padding:2px; border:1px solid #DDD; background:#FFF;}
.input_ocurrent:hover, .input_ocurrent:focus { border:1px solid #444; background:#DDD;}
.input_current { padding:2px; border:1px solid #444; background:#DDD;}
</style>
<script type="text/javascript">
function displayInput(elementID) {
//得到span标签的集合
var spanzone = document.getElementsByTagName("span");
//得到span标签的数量(放到for里边会重复计算)
var spanlength=spanzone.length;
var inputzone;//你所需要的那个span
for(var i=0;i<spanlength;i++)
{
//得到你想找的这个
if(spanzone[i].className==elementID)
{
inputzone=spanzone[i];
}
}
//得到span标签的input标签集合
var inputTx=inputzone.getElementsByTagName("input");
//span里边的input的集合数量(单独写防止重复计算)
var inputLength=inputTx.length;
for (var i=0;i <inputLength; i++) {
//动态添加onmouseover事件:当鼠标移到input上的时候判断这个inpu的class是不是input_ocurrent 如果是的话就添加onmouseover事件 移出同理
if (inputTx[i].className =="input_ocurrent"){
inputTx[i].onmouseover=function() {
this.className ="input_current";
}
inputTx[i].onmouseout=function() {
this.className ="input_ocurrent";
}
}
}
}
window.onload =function() {
displayInput("input_zone");
}
</script>
</head>
<body>
<span class="input_zone">
<input class="input_ocurrent" name="" type="text" size=""/>
<input class="input_ocurrent" name="" type="text" size=""/>
</span>
</body>
</html>
高通与谷歌联手!首款骁龙PC优化Chrome浏览器发布
高通和谷歌日前宣布,推出首次面向搭载骁龙的Windows PC的优化版Chrome浏览器。
在对骁龙X Elite参考设计的初步测试中,全新的Chrome浏览器在Speedometer 2.1基准测试中实现了显著的性能提升。
预计在2024年年中之前,搭载骁龙X Elite计算平台的PC将面世。该浏览器的提前问世,有助于骁龙PC问世就获得满血表现。
谷歌高级副总裁Hiroshi Lockheimer表示,此次与高通的合作将有助于确保Chrome用户在当前ARM兼容的PC上获得最佳的浏览体验。