Jquery搜索父元素操作方法
使用js或者jquery查找父元素、子元素经常遇到。可是用起来总容易混淆,这里统一总结了一下,以后用起来相信会方便好多
这里jquery向上查找父元素 用到的方法:
closest() parents() parent()
向下查找子元素
用到的方法:find() children()
js用的是 children[] 属性 !
jquery怎么隐藏父节点
在jQuery中隐藏父节点,可以使用parent()方法选择该节点的父节点,再调用hide()方法进行隐藏。例如,可以使用$(this).parent().hide()来隐藏当前节点的父节点。需要注意的是,隐藏父节点也会同时隐藏其所有子节点。因此,在隐藏之前需要确认该操作的影响范围。
jquery打开页面window.location和window.open的区别
window.location = "http://www.xxxxxxxx.net" 跳转后有后退功能
其实应该是 window.location.href
window.location.replace("http://www.xxxxxxxx.net") 跳转后没有后退功能
window.open("http://www.xxxxxxxx.net") 要新的窗口打开链接
这个一般用于简单的弹出页面,现在基本上都被屏蔽掉了window.location.reload();window.location = "/Admin/UserList";window.open("/Admin/UserList");
window.location.href = '/Admin/UserList';
window.location.reload()刷新当前页面.
parent.location.reload()刷新父亲对象(用于框架)
opener.location.reload()刷新父窗口对象(用于单开窗口)
top.location.reload()刷新最顶端对象(用于多开窗口)
都是重定向
还没有评论,来说两句吧...