0

I'm trying to convert the following CSS

img.rsImg.rsMainSlideImage {
    display: inline-block;
}

Into Javascript

$('img').closest('.rsImg').closest('.rsMainSlideImage').css('display', 'inline-block');

And something I'm doing seems to be a bit off. I used the same script with a single div and it worked, but this is a bit nested.

6
  • add your HTML markup as well. Commented Mar 12, 2018 at 18:17
  • The closest() method seeks outward. Why aren't you simply putting your selector in the initial argument? Commented Mar 12, 2018 at 18:19
  • Also, add any css stylesheet you have that may be affecting this or it's outer HTML. You may have another style overriding what you are attempting manipulate here. Commented Mar 12, 2018 at 18:20
  • @isherwood, this is only going to find a .rsMainSlideImage with a child .rsImg with a child img. :)) Commented Mar 12, 2018 at 18:28
  • Not the CSS rule. The CSS rule matches an image with the classes rsMainSlideImage and rsImg. closest() searches up the DOM. Commented Mar 12, 2018 at 18:31

1 Answer 1

4

What about

$("img.rsImg.rsMainSlideImage").css("display", "inline-block");
Sign up to request clarification or add additional context in comments.

1 Comment

Ended up going with the following, It ends up getting overwritten by royalslider on load. .rsContent { visibility: hidden; }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.