嘿傢伙, 下面的代碼工作正常......我添加了#wpf-wrapper哈希到#wpf-wrapper裏面的所有鏈接。jquery:將#hash添加到所有鏈接,如果它還沒有?
$('#wpf-wrapper a').live('click',function() {
$(this).attr('href', $(this).attr('href') + "#wpf-wrapper");
});
但是,如果存在已經具有例如href="#"
我不想再添加一個。爲什麼下面的代碼不工作?
$('#wpf-wrapper a').not('#wpf-wrapper a[href="#"]').live('click',function()
$(this).attr('href', $(this).attr('href') + "#wpf-wrapper");
});
突然沒有我的鏈接獲得這個#wpf-wrapper添加?
是否有一個原因,你想在點擊處理程序而不是預先做到這一點? – user113716 2011-02-25 14:56:01