为什么这个查询不能正常工作?data-target 属性是否无法识别另一个元素?
JS
$('button').click(function(){
// uses the button's "data-target" attribute to identify another element to toggle
target = $('#' + $(this).data('target'));
// toggles the visibility of the target
if (target.is(':visible')) {
target.slideUp();
} else {
target.slideDown();
}
// says goodbye if it was hidden
if (target.is(':hidden')){
alert('goodbye, cruel world!');
}
});