请教一下Jquery的unbind 和 bind函数用法
本文介绍了请教一下Jquery的unbind 和 bind函数用法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问 题
formValidate: function(){
$("input[type='image']").unbind("click");
$("input[type='image']").bind("click", function(){
if ($("select[name='did'] option:selected").attr("value") == "") {
alert("请选择部门");
return false;
}
else {
if (!$("select[name='pids'] option:selected").attr("value")) {
alert("请选择岗位");
return false;
}else{
if($("#message").text()=="该用户名已经存在"){
alert("请输入合理的用户名");
return false;
}else{
return true;
}
}
return true;
}
});
解决方案
本质上就是on和off的一个快捷方法
直接看源码吧
https://github.com/jquery/jqu...
bind: function( types, data, fn ) {
return this.on( types, null, data, fn );
},
unbind: function( types, fn ) {
return this.off( types, null, fn );
},
这篇关于请教一下Jquery的unbind 和 bind函数用法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文