1
我正在開發一個元素組,並希望在元素的'focusout
事件觸發器中觸發某些功能。一種監控jquery中元素焦點出現的方法
但是我必須監視聚焦發生的方式,這會引起焦點。
承擔元素A的focusout
是綁定如果在element B
用戶點擊該事件的內容應調用function_B
,如果在element C
用戶點擊該事件的內容應該調用function_C
。和元件B,C不應該是內部元件A.
pseudo code :
$(element_A).focusout(function() {
element_user_interaction = wether user clicks on element_B or element_C
if(element_user_interaction == element_B){
function_B();
}else if(element_user_interaction == element_C){
function_C();
}
});
I found a code from SO. see the accepted answer
$(document).mouseup(function (e)
{
var container = $("YOUR CONTAINER SELECTOR");
if (!container.is(e.target) // if the target of the click isn't the container...
&& container.has(e.target).length === 0) // ... nor a descendant of the container
{
container.hide();
}
});
我嘗試,但不能改變上面的代碼以匹配的僞代碼。
看到更多詳細信息我不知道這一個,thx! –
世界充滿了驚喜:-) – Stepashka
爲什麼我一直在爲'e.relatedTarget'獲得'null' – prime