我的JQuery代码出了什么问题?
<script type="text/javascript">
$(".header").click(function () {
$header = $(this);
//getting the next element
$content = $header.next();
//open up the content needed - toggle the slide- if visible, slide up, if not slidedown.
$content.slideToggle(500, function () {
//execute this after slideToggle is done
//change text of header based on visibility of content div
$header.text(function () {
//change text based on condition
return $content.is(":visible") ? "Collapse" : "Expand";
});
});
</script>
当我将鼠标悬停在结束脚本标记上时,它会显示“期待更多源字符”。
答案 0 :(得分:3)
您只关闭了两个已声明的匿名函数(以及封闭函数调用)。请尝试在});
之前添加其他</script>
。