gpt4 book ai didi

javascript - 如何在 jQuery 中隔离 div?

转载 作者:行者123 更新时间:2023-11-28 08:23:16 26 4
gpt4 key购买 nike

我正在尝试暂停视差 div 并将其替换为静态图像。下面的 jQuery 代码运行得很好,但它杀死了所有其他 div(我在下面的代码中只添加了一个作为示例)。我怎样才能隔离<section>中的div面积?

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Close to Working</title>

<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<style>
.parallax-layer {
position:absolute;
}
.hundred {
width:auto;
height: 390px;
}

</style>
</head>

<body>
<div style="background-color:rgba(0, 0, 0, 0.3)">
<img src="./images/top_logo.png" alt="" />
</div>
<section>
<button class='pushme'>Pause Sliding Images</button>
<script>
$(".pushme").click(function () {
var $el = $(this);
$el.text($el.text() == "Resume Sliding Images" ? "Pause Sliding Images": "Resume Sliding Images");
});
</script>
<div class="hundred">
<div id="port" style="position:relative;top:-15px;">
<div style="left: 0%; margin-left: 0;" class="parallax-layer">
<div>
<img src="./images/para.png" alt="" class="fadeIn fadeIn-4s fadeIn-Delay-4s" />
</div>
</div>
</div>
</div>
</section>
<div style="display: none"><img src="./images/ch_logo.png" alt=""/></div>
<script>
$( "button" ).click(function() {
$( "div" ).toggle( "slow" );
});
</script>

<script type="text/javascript" src="para3_files/jquery_002.js"></script>
<script type="text/javascript" src="para3_files/jquery_003.js"></script>
<script type="text/javascript" src="para3_files/jquery.js"></script>
<script type="text/javascript">
jQuery(document).ready(function(xvalue){
// Declare parallax on layers
jQuery('.parallax-layer').parallax({
mouseport: jQuery("#port"),
yparallax: false
});
});
</script>
<script type="text/javascript" src="./js/home2.js"></script>
</body>
</html>

最佳答案

如果您正在谈论 $( "div" ).toggle( "slow" );切换您所有的div s,那是因为这就是它正在做的事情。

如果您使用$( "section div" ).toggle( "slow" ); ,它只会切换 div位于 section

关于javascript - 如何在 jQuery 中隔离 div?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22739497/

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