0
<div id="dialogButtons" class="opportunityEditorPopup">
<span id="closed" class="label checkOption" style="display: none;"><input type="checkbox">Mark this as closed</span>
<span class="testButtons" style="display: inline;">
<button id="closeOpportunityButton" class="jqButton imaged ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" title="Close this opportunity" role="button"><span class="ui-button-text">Close</span></button>
<button id="newOrderButton" class="jqButton imaged ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" title="Raise New Quote" role="button"><span class="ui-button-text">New Quote</span></button>
</span>
</div>
所以我目前有以下的HTML,我想引用JQuery中的「closeOpportunityButton」。參考一個類中的按鈕ID
我有麻煩來然而,這並嘗試以下操作:
$('.testButtons #closeOpportunityButton').click(function(){
console.log("test")
});
和
$('#dialogButtons .testButtons #closeOpportunityButton').click(function(){
console.log("test")
});
無論其工作。
想法?
ID都是唯一的,這樣只是'$( 「#closeOpportunityButton」)上( 「點擊」,函數(){的console.log( 「測試」)。 });'就夠了 – mplungjan
你的代碼可以單獨運行:https://jsfiddle.net/a83ov97r/。檢查控制檯是否存在潛在的錯誤 –
正如其他人所說的,ID是唯一的,你是否碰巧在你的文檔中有另一個ID = closeOpportunityButton? –