$符号javascript中有什么作? $() 方法是在DOM中的 document.getElementById() 方法的一个便利的简写。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 var $ = function (obj){return document.getElementById(obj);}以后document.getElementById("AC") 可以直接写为$("AC") 呵呵,上面那位不知道这样行不行?var aa = function (obj){return document.getElementById(obj);}以后document.getElementById("AC") 可以直接写为aa("AC") 你这样写是对的 任意字母都可以 呵呵 今天看了这里终于搞懂$做什么用了顺便总结下 呵呵 <!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>test</title> <style type="text/css"> body{ padding-left:3px; overflow:auto; background:transparent; margin-right:3px; background-repeat: no-repeat; } .d{ border-style:solid;border-width:1px;border-color:orange; } </style> <script type="text/javascript"> var $ = function (idValue){ return document.getElementById(idValue); } var $F = function(idValue){ return document.getElementById(idValue).value; } function showValue(){ alert( $("txtInput").value); } </script></head><body onclick="$("xiaoyizhi").style.display=none;"> <div class="d" id="xiaoyizhi" style="width:400px;height:300px;"> <input id="txtInput" type="text" class="d" onblur="showValue();"> <input id="txtInput2" type="text" class="d" onblur="alert($F(this.id));;"> </div></body></html> 作用域问题! 请教一个AJAX问题,请高手帮忙 通过数组无法读取Cookie值中密码,却能读取用户名!!为什么? IE7、8下如何用javascript判断是否刷新 请教大虾,急~~~ javascript如何读取动态控件的值? 这样一试,IE真滴很慢,像蜗牛! 关于小数位的问题 按回车键能使光标能从一个文本框移动到另一个文本框再移动到下来框,还有复选框,单选框 如何实现两个文本框联动? js:为何老提示尚未实现?? MS.NET AJAX里的有些代码看不懂,求教!
以后document.getElementById("AC") 可以直接写为$("AC")
var aa = function (obj){return document.getElementById(obj);}
以后document.getElementById("AC") 可以直接写为aa("AC")
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>test</title>
<style type="text/css">
body{
padding-left:3px;
overflow:auto;
background:transparent;
margin-right:3px;
background-repeat: no-repeat;
}
.d{
border-style:solid;border-width:1px;border-color:orange;
}
</style>
<script type="text/javascript">
var $ = function (idValue){
return document.getElementById(idValue); }
var $F = function(idValue){
return document.getElementById(idValue).value;
}
function showValue(){
alert( $("txtInput").value);
}
</script>
</head><body onclick="$("xiaoyizhi").style.display=none;">
<div class="d" id="xiaoyizhi" style="width:400px;height:300px;">
<input id="txtInput" type="text" class="d" onblur="showValue();">
<input id="txtInput2" type="text" class="d" onblur="alert($F(this.id));;">
</div>
</body>
</html>