gpt4 book ai didi

单击时 JavaScript 不工作

转载 作者:行者123 更新时间:2023-11-28 06:15:56 26 4
gpt4 key购买 nike

我试图让 div 在单击时向上滑动或向下滑动,但单击时没有任何反应。我正在遵循教程,检查了所有内容,但似乎找不到问题。请帮助并解释我做错了什么,我正在学习,并且犯了很多愚蠢的错误,所以不要讨厌:)

<!DOCTYPE html>

<head>
<script src="/assets/jquery.js"></script>
<link href='https://fonts.googleapis.com/css?family=Londrina+Shadow' rel='stylesheet' type='text/css'>
<style>
body {
font-family: helvetica, sans-serif;
margin: 0 auto;
max-width: 600px;
background: #232323;
}
div {
height: 200px;
background-size: cover;
position: relative;
margin: 40px 0 0 0;
border-radius: 12px;
}
h1 {
font-family: 'Londrina Shadow', cursive;
text-align: center;
font-size: 75px;
color: #aaaaaa;
margin: 60px 0 0 0;
}
h2 {
text-align: center;
color: #bbbbbb;
margin: 0px 0 70px 0;
}
p {
color: rgba(255,255,255,1);
background: black;
background: linear-gradient(bottom, rgba(0,0,0,1), rgba(0,0,0,.4));
background: -webkit-linear-gradient(bottom, rgba(0,0,0,1), rgba(0,0,0,.4));
background: -moz-linear-gradient(bottom, rgba(0,0,0,1), rgba(0,0,0,.4));
padding: 10px;
line-height: 28px;
text-align: justify;
position: absolute;
bottom: 0;
margin: 0;
height: 30px;
}
small{
opacity: 0;
}
.show-description p{
height: 150px;
}
.show-description small{
opacity: 1;
}

.first{
background-image: url("http://dash.ga.co/assets/firstcourse.jpg");
}
.second{
background-image: url("http://dash.ga.co/assets/secondcourse.jpg");
}
.dessert{
background-image: url("http://dash.ga.co/assets/dessertcourse.jpg");
}
.price {
float: right;
}
@media (max-width: 500px){
h1{
font-size: 50px;
margin-top: 20px;
line-height: 40px;
}
h2{
font-size: 20px;
margin: 20px 0 30px 0;
}
div{
margin: 20px 12px 0 12px;
}
p{
font-size: 20px;
line-height: 24px;
}
small{
font-size: 16px;
}
}
</style>

</head>

<body>
<h1>esha's restaurant</h1>
<h2>a New York City eatery</h2>
<div class="first">
<p>welsh onion soko <span class="price">$14</span><br />
<small>Mustard sierra leone bologi kale chard beet greens black-eyed pea sorrel amaranth garlic tigernut spring onion summer purslane asparagus lentil. </small></p>
</div>

<div class="second show-description">
<p>pastrami boudin tongue <span class="price">$22</span><br />
<small>Tri-tip capicola kielbasa salami brisket chicken rump strip steak drumstick. Meatloaf chuck boudin ribeye pork jowl. Andouille bacon jowl meatloaf pork loin prosciutto bresaola.</small></p>
</div>

<div class="dessert">
<p>fruitcake marzipan pudding dragee <span class="price">$8</span><br />
<small>Lollipop tart cotton candy jelly-o carrot cake apple pie cupcake. Jelly-o bear claw ice cream candy canes.</small></p>
</div>
<script>
$('div').on('click', function() {
$(this).toggleClass('show-description');
});
</script>
</body>

最佳答案

我遇到了同样的问题,请确保您的附加组件不会干扰。我不得不禁用一些广告拦截。是的,我通过控制台发现了这一点,所以感谢大家对此的评论。

如果您逐字遵循教程,我认为没有必要更改库的源代码。

关于单击时 JavaScript 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35965454/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com