0

Suppose the following snippet

<div class="class-a">
   <a href="#">Hello</a>
   <ul>
     <li>
       <a href="#">Hello A</a>
     </li>
     <li>
       <a href="#">Hello B</a>
     </li>
   </ul>
</div>

how select a tag which contains hello text by sass in class-a. please help me.

azmul hossain
  • 1,321
  • 2
  • 11
  • 15

2 Answers2

0

Try this :

HTML

<ul>
    <li>a</li>
    <li>b</li>
    <li>c</li>
    <li>d</li>
</ul>

SCSS

$colors: red, orange, yellow, green, blue, purple;

@for $i from 1 through length($colors) {
  li:nth-child(#{length($colors)}n+#{$i}) {
    background: lighten(nth($colors, $i), 20%);
  }
}

checkout the live : https://codepen.io/cimmanon/full/yoCDG/

Siful Islam
  • 1,906
  • 3
  • 21
  • 31
0

Short answer, no.

CSS (what Sass compiles into) is a presentation language, it has no knowledge of the content of the page.

The best option would be to decorate all the fields you want styled with a css class and then just use that css class.

If you want to set these classes via JQuery, I think the code you're looking for is this: $('a:contains("Hello")').addClass('helloStyle');

As ewcz commented, here is a link to a duplicate question. Is there a CSS selector for elements containing certain text?

Community
  • 1
  • 1
k2snowman69
  • 1,849
  • 1
  • 14
  • 19