Solution 1 :

Try:

li a[href='https://someweb.com/']:eq(1)
$("li a[href='https://someweb.com/']:eq(1)").css("background","red");
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  <li>
  <a href="https://someweb.com/"> 1 </a>
  </li>
  <li>
  <a href="https://someweb.com/"> 2 this is what i need to select </a>
  </li>
  <li>
  <a href="https://someweb.com/"> 3 </a>
  </li>

Solution 2 :

You want to select that specific URL?

a[href='https://specificWeb.com/']{
 background: red;
 }
<a href="www.link.com">CATEGORY NAME</a>
                                                                                                                                                                                        <div class="123">
    <div class="categories ">
      <span>Categories:</span>
      <ul>
      <li>
      <a href="https://someweb.com/"> 1 </a>
      </li>

      <li>
      <a href="https://specificWeb.com/"> 2 this is what i need to select </a>
      </li>
      
      </ul>
    </div>
  </div>

But i think a better solution will be by using classes:

.my-target-url {
 background: red;
 
 }
<a href="www.link.com">CATEGORY NAME</a>
                                                                                                                                                                                        <div class="123">
    <div class="categories ">
      <span>Categories:</span>
      <ul>
      <li>
      <a href="https://someweb.com/"> 1 </a>
      </li>

      <li>
      <a class="my-target-url"href="https://specificWeb.com/"> 2 this is what i need to select </a>
      </li>
      
      </ul>
    </div>
  </div>

And if urls are not hardcoded, add a logic that toggles the class

Problem :

Looking for option in js/css to select (n) <li> in my code, but i need to have indicate that <li> have parent with current <a> with specyfic indicated href link.

<a href="www.link.com">CATEGORY NAME</a>
                                                                                                                                                                                        <div class="123">
    <div class="categories ">
      <span>Categories:</span>

      <ul>
        <li>
            <a href="https://someweb.com/"> 1 </a>
        </li>
        <li>
            <a href="https://someweb.com/"> 2 this is what i need to select </a>
        </li>
      </ul>
    </div>
 </div>
        

Many thanks for respound!
Cheers!

By

Leave a Reply

Your email address will not be published. Required fields are marked *