[英]Input text and button field does not work in firefox
我正在使用JQUERY小部件的某些應用程序上工作。 在該小部件中,有一些輸入字段,例如文本,文本區域和按鈕。 我只能通過TAB訪問這些字段,但是直接用鼠標單擊無法完成。 這個應用程式可以在Chrome上正常運作。 具有這些字段的簡單html可以工作,但是當我在js文件中添加這些字段,然后在其他js文件中調用這些文件時,這些字段在Firefox中不起作用。
這是js文件:
var AddNewDepartment = "<br />\
<form>\
<table class='AddNewDepartment-table'>\
<tr>\
<td>\
Department Name:<span style='color: red'>*</span> \
<input type='text' name='departmentName' id='departmentName' class='expanded-input-text' />\
<input type='button' name='save' id='save' onclick='createDepartment()' Value='Save' class='newDepartment-submit' />\
<input type='button' name='cancel' Value='Cancel' class='newDepartment-submit' />\
</td>\
</tr>\
</table>\
</form>\
";
請,我需要幫助來解決這個問題。
從您的帖子中看來,您是在將表單動態添加到DOM,即在頁面加載之后。 在這種情況下,您需要為其進行委托事件處理。
您可以嘗試使用.on()
,如下所示:
$(document).on('click', 'form AddNewDepartment-table input,form AddNewDepartment-table textarea', function() {
// your code
});
對於委托事件處理, .on()
的語法為:
$(StaticParent).on( eventName, targets, handlerFunction );
在這里, StaticParent
表示不是動態的DOM元素,並且在頁面加載時屬於DOM。 eventName
可能用空格分隔以用於多個事件綁定。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.