問題:
js綁定的事件要比Ajax動態(tài)添加的數(shù)據(jù)執(zhí)行的早,所以說動態(tài)添加的數(shù)據(jù)沒有綁定上JS事件。
解決辦法:
1、寫一個js事件的方法,不要在頁面加載時啟用.
function clickkw(){
? ? ? ? ? ? $("#kwpipei .dropdown-item").on('click',function(){
? ? ? ? ? ? ? ? var txt2 = $(this).html();
? ? ? ? ? ? ? ? var txt3 = txt2.split("-");
? ? ? ? ? ? ? ? window.location.href="{:url('index/newsreleases')}?search="+txt3[0]+"|搜索&type=search";
? ? ? ? ? ? });
? ? ? ? }
2、Ajax回調(diào)完再調(diào)用剛剛寫的事件就可以了。
