我是新来的JavaScript/jQuery和我目前有显示在按钮收藏不同内容的问题,请单击使用JavaScript/jQuery的显示在收藏夹不同的内容单击按钮时
我创建了被认为两个按钮在按钮被点击时显示具有不同内容的灯箱。对于每个按钮,灯箱内的内容应该不同,但目前情况并非如此。
当我试图改变第一h3
和p
标记为第一个按钮,它只是重叠为第二个按钮的第二h3
和p
标签。我相信问题在于javascript代码,但我无法弄清楚如何在按钮点击时为每个灯箱显示不同的内容。
这里是我的HTML/Javascript代码:
<!DOCTYPE html>
<html lang="no">
<head>
<title>FantasyLab</title>
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
<link rel="stylesheet" type="text/css" href="css/style.css">
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script>
<link href='http://fonts.googleapis.com/css?family=Source+Sans+Pro' rel='stylesheet' type='text/css'>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript">
$(document).ready(function(){
$('.lightbox').click(function(){
$('.backdrop, .box').animate({'opacity':'.50'}, 300, 'linear');
$('.box').animate({'opacity':'1.00'}, 300, 'linear');
$('.backdrop, .box').css('display', 'block');
});
$('.close').click(function(){
close_box();
});
$('.backdrop').click(function(){
close_box();
});
});
function close_box()
{
$('.backdrop, .box').animate({'opacity':'0'}, 300, 'linear', function(){
$('.backdrop, .box').css('display', 'none');
});
}
</script>
</script>
</head>
<body bgcolor="#060e19">
<div class="page-wrap">
<a href="#" class="lightbox" id="contact">Kom i kontakt</a>
<div class="box">
<div class="close"><i class="fa fa-times fa-1x"></i></div> <!-- end of close -->
<h3 class="title">Kom i kontakt</h3>
<p>Kontakt oss for mer informasjon</p>
<div class="container">
<form id="newsletter-subscription" action="" method="post">
<fieldset>
<input placeholder="Fornavn" type="text" tabindex="1" required autofocus>
</fieldset> <!-- end of fieldset -->
<fieldset>
<input placeholder="Etternavn" type="text" tabindex="2" required autofocus>
</fieldset> <!-- end of fieldset -->
<fieldset>
<input placeholder="E-postadresse" type="email" tabindex="3" required>
</fieldset> <!-- end of fieldset -->
<fieldset>
<input placeholder="Telefonnummer" type="tel" tabindex="4" required>
</fieldset> <!-- end of fieldset -->
<fieldset>
<input placeholder="Webside http://" type="url" tabindex="5" required>
</fieldset> <!-- end of fieldset -->
<fieldset>
<button name="submit" type="submit" id="contact-submit" data-submit="...Sending">Send inn</button>
</fieldset>
</form> <!-- end of form -->
</div> <!-- end of container -->
</div> <!-- end of box-content -->
<a href="#" class="lightbox" id="subscribe">Meld deg på vår nyhetsbrev</a>
<div class="backdrop"></div> <!-- end of backdrop -->
<div class="box">
<div class="close"><i class="fa fa-times fa-1x"></i></div> <!-- end of close -->
<h3 class="title">Abonner på nyhetsbrev</h3>
<p>Motta informasjon rundt lanseringsdato, kampanjer og tilbud.</p>
<div class="container">
<form id="newsletter-subscription" action="" method="post">
<fieldset>
<input placeholder="Fornavn" type="text" tabindex="1" required autofocus>
</fieldset> <!-- end of fieldset -->
<fieldset>
<input placeholder="Etternavn" type="text" tabindex="2" required autofocus>
</fieldset> <!-- end of fieldset -->
<fieldset>
<input placeholder="E-postadresse" type="email" tabindex="3" required>
</fieldset> <!-- end of fieldset -->
<fieldset>
<input placeholder="Telefonnummer" type="tel" tabindex="4" required>
</fieldset> <!-- end of fieldset -->
<fieldset>
<input placeholder="Webside http://" type="url" tabindex="5" required>
</fieldset> <!-- end of fieldset -->
<fieldset>
<button name="submit" type="submit" id="contact-submit" data-submit="...Sending">Send inn</button>
</fieldset>
</form> <!-- end of form -->
</div> <!-- end of container -->
</div> <!-- end of box-content -->
</div> <!-- end of main-content -->
</div> <!-- end of page-wrap -->
</body>
</html>
任何帮助表示赞赏。
谢谢,您的解决方案藏汉为我工作。 – NohmanJ