0

I know SASS allows for conditionals and I want to know if I could leverage this to do the following DOM manipulation instead of writing it in JQuery/JS.

The problem

In my HTML there is an element with an attribute data-tab-current. This attributes value is changing dynamically IE:

data-tab-current = "1"

data-tab-current = "2"

data-tab-current = "3"

data-tab-current = "4"

data-tab-current = "5"

When the value is 4 I want to change the CSS of another element. This element is not a child, sibling or descendant of data-tab-current = "4".

The logic for what I want to do looks like this:

if(dataTabCurrent == 4){

    $("my-other-elment).css("display","none")
}
William
  • 3,608
  • 11
  • 41
  • 85

1 Answers1

0

If your target element is not a descendant of your element with data-tab-current attribute - then there is no way to implement in in CSS because such solution is, basically, requires parent reference selector to be in CSS and there is (currently?) no such selector is available. Please refer this answer on SO for more information.

Sass is just a pre-processor, it can't add anything to CSS itself, it is just a way to develop CSS code more effectively.

Flying
  • 4,104
  • 2
  • 14
  • 24