这句JS是什么意思。如何调用

来源:百度知道 编辑:UC知道 时间:2024/05/10 13:13:46
$ = function(id){
return document.getElementById(id);
}
我想知道如何调用他。比如onclick之类的。如果不调用写在JS里就没意义了不是么?

通过网页控件(元件)的ID获取该控件的句柄,用于在js中操作控件。

比如一个文本框的ID为"txt_name"
要取出它的值可以这么做:
$("txt_name").value

<input type="textbox" name="textbox1" value="" />
<input type="button" name="button1" onclick="javascript:document.write($$("txt_name").value)" />