首页 新闻 搜索 专区 学院

Jquery绑定的事件问题

0
[已解决问题] 解决于 2008-03-21 09:12
<P>&nbsp;&lt;script type="text/javascript"&gt;<BR>&nbsp;&nbsp;&nbsp; function dblclick()<BR>&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var textbox = document.createElement("text");<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; textbox.value = obj.innerTEXT;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; textbox.id = obj.id + 1;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $(obj).after(textbox);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $(obj).hide();<BR>&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; $(document).ready(function()<BR>&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var as = $("#tdtree").find("a[href *= '_doPostBack']");</P> <P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; as.each(function (q){<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(as[q].ondblclick == null)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; alert(1);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $(as[q]).bind("ondblclick",dblclick);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; });<BR>&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp; );<BR>&nbsp;&nbsp;&nbsp; &lt;/script&gt;</P> <P>请问,我这样写为什么绑定不了事件,查看了很多例子都可以,我用as[q].ondblclick = dblclick 这样可以,另外请问我如何穿参数</P>
仁面寿星的主页 仁面寿星 | 菜鸟二级 | 园豆:325
提问于:2008-03-20 17:32
< >
分享
最佳答案
0
as.each(function (q){ if(as[q].ondblclick == null) { alert(1); $(as[q]).bind("ondblclick",dblclick); } }); --- 修改为: as.dblclick(function(){ return dblclick(); });
没剑 | 菜鸟二级 |园豆:430 | 2008-03-20 23:04
其他回答(1)
0
var textbox = document.createElement("text"); 试试换成: var textbox = document.createElement('input');
deerchao | 园豆:8167 (大侠五级) | 2008-03-20 21:38
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册