我有下面的代碼:使用Javascript - 在點擊處理忽略/跳過
$(document).on('click','#tab-personal',function(e){
loadit('personal');
});
和
$("#tab-personal").click(function()
{
});
,當我:
$(document).ready(function(){
var rebuild = getParameterByName("rebuild");
var createdStructures = $('#AtoZContentDiv').children().length;
if ((rebuild !== undefined && rebuild !== null && rebuild.indexOf("true") === 0) || (createdStructures === 0))
{
// clean up pre-existing data
cleanUp();
// create container structure
createFormLinkContainers();
// Call SP web services to retrieve the information and create the A to Z
retrieveListData();
completeInitialization();
}
else
{
aggregateAll = jQuery.parseJSON($('#hdnAggregateAll').val());
aggregatePersonal = jQuery.parseJSON($('#hdnAggregatePersonal').val());
aggregateBusiness = jQuery.parseJSON($('#hdnAggregateBusiness').val());
ministryAggregate = jQuery.parseJSON($('#hdnMinistryAggregate').val());
caAggregate = jQuery.parseJSON($('#hdnCAAggregate').val());
sTaxAggregate = jQuery.parseJSON($('#hdnSTaxAggregate').val());
bTaxAggregate = jQuery.parseJSON($('#hdnBTaxAggregate').val());
leTaxAggregate = jQuery.parseJSON($('#hdnLETaxAggregate').val());
var type = getParameterByName("filter");
$("#tab-all").click(function()
{
loadit('all');
});
$("#tab-business").click(function()
{
loadit('business');
});
$("#tab-personal").click(function()
{
});
$(document).on('click','#tab-personal',function(e){
loadit('personal');
});
buildFilterMenu();
loadit('all');
}
});
我一直在使用這兩種嘗試在他們中間放置一個斷點,沒有一個被擊中。
HTML:
<div id="tabs" style="display: inline-block;">
<ul><li><a class="selected" id="tab-all" href="#" type="all"><b>All Forms</b></a></li>
<li><a id="tab-business" href="#" type="business"><b>Business</b> </a></li>
<li><a id="tab-personal" href="#" type="personal"><b>Personal</b> </a></li></ul>
</div>
全碼:http://pastebin.com/vzLPX3cU
這究竟是爲什麼?
你嘗試執行添加聽衆在控制檯?試試這個:$(「#tab-personal」).on(「click」,function(){console.log(「click!」); }); – Sabik
我在Chrome的開發人員工具調試器中放置了一個斷點。我曾嘗試把一個console.log('<<<<個人'),但代碼沒有被擊中。 – Brian
與你的例子DOM作品https://jsfiddle.net/k06w4mos/。也許你有一些錯誤,你的代碼不能完全執行? – Sabik