[英]onClick Function for Link Not Working
I am a beginner in jQuery & JavaScript and have been hacking away to try and get a function working on my website. 我是jQuery&JavaScript的初学者,并且一直在努力尝试并在我的网站上使用某个功能。
The page loads with sections hidden via CSS and revealed when the user clicks a link. 该页面加载了通过CSS隐藏的部分,并在用户单击链接时显示。 I have it working but in trying to make it more usable later for other buttons I am trying to turn it into a function which cause it to break. 我有它的工作,但试图稍后使它对其他按钮更有用,我试图将其转换为导致其中断的功能。
$(".bed-breakfast-explore").hide();
$("#bed-breakfast-menu").hide();
function discoverBedBreakfast() {
$(".bed-breakfast-explore").slideToggle("slow");
$(".hotel").css("display", "none");
$(".resort").css("display", "none");
$(".guest-house").css("display", "none");
$("#bed-breakfast-menu").show();
$('html, body').animate({ 'scrollTop': $('#bed-breakfast-menu').offset().top - 86}, 1300);
}
The HTML for the link is: 链接的HTML是:
<a class="button" href="#" onclick="discoverBedBreakfast()">Explore</a>
place it like 放置像
<head>
<script src="jquery-2.1.4.min.js"></script>
<script >
$(document).ready(function(){
$(".bed-breakfast-explore").hide();
$("#bed-breakfast-menu").hide();
})
function discoverBedBreakfast() {
$(".bed-breakfast-explore").slideToggle("slow");
$(".hotel").css("display", "none");
$(".resort").css("display", "none");
$(".guest-house").css("display", "none");
$("#bed-breakfast-menu").show();
$('html, body').animate({ 'scrollTop': $('#bed-breakfast-menu').offset().top - 86}, 1300);
}
</script>
</head>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.