我想通过点击一个按钮来隐藏一个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();
});

更多信息
jsFiddle Demonstration
jQuery.click()
jQuery.parent()
jQuery.hide()

关于jquery - 如何通过单击其中的按钮隐藏div,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/8987031/

10-12 00:09
查看更多