gpt4 book ai didi

JavaScript - removeClass 不工作?

转载 作者:行者123 更新时间:2023-11-28 15:58:51 25 4
gpt4 key购买 nike

我有一个 jssor 画廊,我通过添加 CSS 类“blur”对其进行了模糊处理。当用户点击 div 时,我想“取消模糊”这个画廊。为此,我添加了这个简单的 JS 代码:

    jQuery(document).ready(function($) {
$("js1").click(function(){
$("jssor_1").removeClass("blur");
});
});

其中“js1”是我的 div 的 ID,“jssor_1”是我的画廊的 ID。不幸的是,这根本不起作用。我是 JS 的新手,但我认为这应该可以正常工作,因为点击功能会检查是否点击了 HTML 元素...这是我的图库的 HTML 代码:

  <div id="gallery" class="section gallery-section">
<div class="container-fluid">
<div id="jssor_1" class="blur" style="top: 0px; left: 0px; width: 800px; height: 445px; overflow: hidden; visibility: hidden; background-color: #000;">
<div data-u="slides" style="cursor: default; top: 0px; left: 0px; width: 800px; height: 400px; overflow: hidden;">
<div data-p="144.50" style="display: none;">
<img data-u="image" src="img/realizacje/01.jpg" />
<img data-u="thumb" src="img/realizacje/01t.jpg" />
</div>
...other gallery images...
</div>
<div data-u="thumbnavigator" class="jssort01" data-autocenter="1">
<div data-u="slides" style="cursor: default;">
<div data-u="prototype" class="p">
<div class="w">
<div data-u="thumbnailtemplate" class="t"></div>
</div>
<div class="c"></div>
</div>
</div>
</div>
<span data-u="arrowleft" class="jssora05l" style="top: 158px; left: 8px; width: 40px; height: 40px;"></span>
<span data-u="arrowright" class="jssora05r" style="top: 158px; right: 8px; width: 40px; height: 40px;"></span>
</div>
<div id="js1" class="naglowekgalerii">PRZYKŁADOWE REALIZACJE</div>
</div>
</div>

CSS:

.blur {
-webkit-filter: blur(5px);
-moz-filter: blur(5px);
-o-filter: blur(5px);
-ms-filter: blur(5px);
filter: blur(5px);
}

.naglowekgalerii {
font-family: 'Bitter', serif;
font-size: 28px;
color: white;
background: none;
padding-left: 24px;
padding-top: 18px;
padding-bottom: 8px;
margin: 0 auto;
text-transform: uppercase;
text-shadow: 1px 1px black;
position: absolute;
top: 50%;
left: 50%;
}

.naglowekgalerii:hover {
cursor:pointer;
}

.jssora05l, .jssora05r {
display: block;
position: absolute;
width: 40px;
height: 40px;
cursor: pointer;
background: url('../img/a17.png') no-repeat;
overflow: hidden;
}
.jssora05l { background-position: -10px -40px; }
.jssora05r { background-position: -70px -40px; }
.jssora05l:hover { background-position: -130px -40px; }
.jssora05r:hover { background-position: -190px -40px; }
.jssora05l.jssora05ldn { background-position: -250px -40px; }
.jssora05r.jssora05rdn { background-position: -310px -40px; }

.jssort01 {
position: absolute;
left: 0px;
width: 760px;
height: 45px;
}

.jssort01 .p {
position: absolute;
top: 0;
left: 0;
width: 60px;
height: 45px;
}

.jssort01 .t {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
border: none;
}

.jssort01 .w {
position: absolute;
top: 0px;
left: 0px;
width: 100%;
height: 100%;
}

.jssort01 .c {
position: absolute;
top: 0px;
left: 0px;
width: 60px;
height: 45px;
}

.jssort01 .pav .c {
top: 0px;
_top: 0px;
left: 0px;
_left: 0px;
width: 60px;
height: 45px;
background: rgba(255,255,255,0.8);
transition: all .3s;
}

.jssort01 .p:hover .c {
top: 0px;
left: 0px;
width: 60px;
height: 45px;
background: rgba(255,255,255,0.8);
transition: all .3s;
}

.jssort01 .p.pdn .c {
width: 60px;
height: 45px;
background: rgba(255,255,255,0.8);
transition: all .3s;
}

最佳答案

JQuery 选择器
JQuery 选择器是一种选择文档对象模型 (DOM) 元素的方法,即 HTML 元素,如 divbutton .. 等

' * '

$("*")  //All elements  

#id

$("#lastname")  //The element with id="lastname"  

.class

$(".intro") //All elements with class="intro"  

.class,.class

$(".intro,.demo")   //All elements with the class "intro" or "demo"

元素

$("p")   //All <p> elements

el1,el2,el3

$("h1,div,p")   //All <h1>, <div> and <p> elements

你的情况

您使用的选择器不正确,您需要使用

jQuery(document).ready(function() {
$("#js1").click(function(){
$("#jssor_1").removeClass("blur");
});
});

关于JavaScript - removeClass 不工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35812206/

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