js中如何使用$
js中想用$获得html中的元素,应该如何写?
------解决方案--------------------
简单的话 function $(s){return document.getElementById(s);}
最好用jquery等框架 http://jquery.org------解决方案--------------------
也可以...
function $(id){
return "string"==typeof(id) ? document.getElementById(s) : id;
}
------解决方案--------------------
function $(str)
{
return (document.getELementById(str));
}
------解决方案--------------------
$()是jquery的一个工厂,它封装的就是dom元素。document,id,className,TagName都可以使括号里的元素,其中$("className")和$("TagName")是自动循环的。
------解决方案--------------------
JScript codefunction $(s){return document.getElementById(s);}
------解决方案--------------------
function $(id){
return "string"==typeof(id) ? document.getElementById(s) : id;
}
查询谷 - www.chaxungu.com
js中怎么使用$
编辑:chaxungu时间:2022-10-02 23:14:31分类:web开发