[英]onClick Function for Link Not Working
我是jQuery&JavaScript的初學者,並且一直在努力嘗試並在我的網站上使用某個功能。
該頁面加載了通過CSS隱藏的部分,並在用戶單擊鏈接時顯示。 我有它的工作,但試圖稍后使它對其他按鈕更有用,我試圖將其轉換為導致其中斷的功能。
$(".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);
}
鏈接的HTML是:
<a class="button" href="#" onclick="discoverBedBreakfast()">Explore</a>
放置像
<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.