直接上代码吧,感兴趣的自己下载回去测试,自定义的$符号和jQuery的$符号混用成功
<!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" /> <title></title> </head> <body> name:<span id="s1"></span><br/> name is:<input type="text" name="myname" id="myname" value="" style="200px;" /> <br/> <button id="b1">自定义的$</button> <button id="b2">jQuery的$</button> </body> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> <script type="text/javascript"> function $(id){return document.getElementById(id);} </script> <script type="text/javascript"> setInterval(function(){document.getElementById("s1").innerHTML=new Date().toLocaleString();},1000); document.getElementById("myname").value=""; (function($){ $("#b2").click(function(){$("#myname").val($("#s1").html());}); })(jQuery); $("b1").onclick=function(){$('myname').value=$('s1').innerHTML;} </script> </html>