简体   繁体   English

使用jQuery选择和更改类的属性?

[英]Selecting and changing the attribute of a class using jQuery?

I've highlighted the class which I want to change one of its attributes... 我突出显示了要更改其属性之一的类...

在此处输入图片说明

How to select and change the opacity attribute and change it to 0.1 using jQuery? 如何使用jQuery选择和更改opacity属性并将其更改为0.1?

I've tried this with no success... 我尝试过这个没有成功...

var item = $('.slide-object slide-object-stategroup shown')

$(item).attr( 'opacity' ): 0.1;
  1. Your selector is wrong. 您的选择器有误。
  2. The way you are changing opacity is wrong. 您更改不透明度的方式是错误的。

See the code below: 请参见下面的代码:

var item = $('.slide-object.slide-object-stategroup.shown')
$(item).css( 'opacity', 0.1);

Use .css method to change any css property. 使用.css方法更改任何CSS属性。 Also classes needs to have a . 另外,班级也需要有一个. before their name. 在他们的名字之前。 Spaces in selector means you are accessing the child. 选择器中的空格表示您正在访问孩子。 So remove the spaces and add a dot in the selector. 因此,请删除空格并在选择器中添加一个点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM