How can I change the attribute of an element, depending on another attribute?
For example, I have 2 <a>
elements. They both have the class myClass
. One of the elements has rel="1"
and the other has rel="2"
. I wish to only change the z-index
on the one which has rel=1
. How do I do this?
I've tried:
$(".myClass[rel='1']").css("z-index", 10);
But it doesn't work. Cheers.
try this:
$(".myClass[rel='1']").css('display', 'none');
and see if it disappears. Then you will know if it is your selector, or positioning.
由于z-index
包含连字符,因此在驼峰情况下必须引用它:
$(".myClass[rel='1']").css("zIndex", 10);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.