你不能綁定單擊並同時解除綁定....
el.click(fn) means that you are binding a click event to that element like the way you have which is fine ....
el.unclick(fn) means that you are unbinding a click function from that element.
USE - >如果你是這樣的el.unclick()
所有點擊事件將綁定從元素 如果您要使用一個功能....
function yourFunc(){
console.log('you clicked me !')}
el.click(yourFunc); // now when you click this el console will show the phrase
//when you unbind the function
el.unclick(yourFunc);
我只是有一種預感,你也許想使用鼠標按下和MouseUp事件....
編輯:您的要求
function sel_unsel(){
if(this.data('selected') == false){
this.data('selected', true);
// do here what you want when element is selected
}else if(this.data('selected') == true){
this.data('selected', false);
//do here what you want when element is unselected
}
}
function elemClick(el){
el.data('selected',false);
el.click(sel_unsel);}
請張貼代碼...點擊並取消選中就像是在拉斐爾的最簡單的事情之一.... – Aukhan 2012-08-01 18:59:22