0

I want to match a JQuery CSS call (modifying CSS so that I can use a variable) with some Javascript div/classes. I can't use "id" because there are many of these instances in a loop. Edit: it is still not quite working and I suspect I need a little more detail here.

The relevant piece of the CSS (there are other transform lines, not shown here):

.thermometer .circle {
    position: absolute;
    ...

.pie {
    position: absolute;
    ...
}

.hold {
    position: absolute;
    ...
    clip: rect(0px, 26px, 26px, 13px);
}

.pieSlice1 .pie {
    background-color: white;
    -webkit-transform:rotate(60deg);
    transform:rotate(60deg);
}

In a JST EJS file:

 <div class="thermometer">
   <div class="circle <%= this.presenter.newColor(nutrient) %>">
     <div class="pieSlice1 hold">
       <div class="pie"></div>
         <% $(".pieSlice1.hold .pie").css({'-webkit-transform': 'rot
ate(22deg)'}); %>

I've removed the space between "pieSlice1" and "hold", but do I need any of the other classes in order to match?

3 Answers 3

2

It should be:

.pieSlice1.hold .pie

without any space between .pieSlice1 and .hold

Sign up to request clarification or add additional context in comments.

3 Comments

thanks, @keune. Please take a look if you get a chance- I added a bit more. I suspect it i s not quite right.
the selector syntax and the css property you're trying to add is right. If it's not working, there should be some other problem.
thanks. I am not sure how to find the other problem. I suspect I need to learn more about javascript debugging, to find out why the match isn't happening. Thanks for all your help.
1

If you want an intersection, just write the selectors together without spaces in between.

$(".pieSlice1.hold .pie").css({'-webkit-transform': 'rot
ate(22deg)'});

When we include space, it looks for descendants...

Another option is:

$(".pieSlice1").filter(".hold .pie").css({'-webkit-transform': 'rot
ate(22deg)'});

2 Comments

Please have a quick second look. I suspect I am still not fully there.
That should work..,If it does not , try .thermometer .pieSlice1.hold .pie
0

Since .pieSlice1 and .hold are both classes on the same element, you need to chain them:

.pieSlice1.hold .pie

Note how there's no space between .pieSlice1 and .hold – that means it will match an element with the class .pie which is a descendant of an element that has both .pieSlice1 and .hold classes.

Whereas with what you have now...

.pieSlice1 .hold .pie

That would match an element with the class .pie which is a descendant of an element with the class .hold, which itself is a descendant of an element with the class .pieSlice1.

1 Comment

#daGUY, thanks so much. Please take another look at the edit - I suspect I still don't have it quite right.

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.