2016-06-15 6 views
1

私は、ナビゲーションをソートするためにしようとしています、すべての親Aはchild.innerHTML除き、/見えない隠されるべき== SORTTYPEJavascriptを非表示フィルタ子innerHTMLの

どのように私はそれを達成することができますか?

function sort_sidebar(type) { 
    if(type && type.substring(0,6) == "#sort=") { 
     $('#id > div > a').hide() 
     // $('#id > div > a > p:last-child > span:last-child').show() where innerHTML == type.slice(6).toUpperCase() 
     history.pushState("", document.title, type) 
     alert(type.slice(6).toUpperCase()) 
    } else { 
     $('#id > div > a').show() 
     history.pushState("", document.title, window.location.pathname + window.location.search) 
    } 
} 

答えて

0

代わりに子供要素からのinnerHTMLを検索、私は親要素を与えた「データ型」innerHTMLのと同じであるattributは、それを

$('#id> div > a').hide().filter('[data-type="'+type.slice(6).toUpperCase()+'"]').show(); 
をフィルタリングします
関連する問題