有沒有一種方法來測試您的當前URL位置是否與頁面上的鏈接匹配,並且還檢查匹配的鏈接是否具有特定的div類?當前的URL和鏈接匹配 - 與div類檢查
例如
jQuery(document).ready(function($){
// find a-href on page with matching current location URL
jQuery("*").find("a[href='"+window.location.href+"']").each(function(){
// if matching a-href contains class .aaa
// then BBB action
// else if matching a-href contains class .bbb
// then CCC action
})});
使用hasClass('aaa')。 – SSA 2014-10-01 14:15:06