我想通过点击其中的一个按钮来隐藏一个 DIV
(不知道 div 的 id 和类)。
可以使用 JQuery
吗?
最佳答案
描述
您可以使用 jQuery 的 click()
、.parent()
和 .hide()
方法执行此操作。
查看我的样本和这个 jsFiddle Demonstration
示例
<div><button>hide</button></div>
<div><button>hide</button></div>
<div><button>hide</button></div>
<div><button>hide</button></div>
$("button").click(function() {
$(this).parent().hide();
});
更多信息
关于jquery - 如何通过单击其中的按钮来隐藏 div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8987031/