I am trying to sort a navigation, every parent A should be hidden / invisible, except the child.innerHTML == sorttype
How can I achieve that?
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)
}
}
相反,从子元素中搜索innerHTML,我给父元素一个“数据类型”attribut,它与innerHTML相同,用于过滤它
$('#id> div > a').hide().filter('[data-type="'+type.slice(6).toUpperCase()+'"]').show();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.