Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Assuming I haven't misunderstood you somewhere: you could have jQuery handle the searching for you with selectors.</p> <p>Assuming your anchor tag contains the actual URL -- it's not clear since you seem to have some incomplete/pseudo-code HTML (e.g. "#", "#LINKHERE" etc) -- you can search against the href directly, e.g.</p> <pre><code>$("a[href=" + url + "]") </code></pre> <p>will select an anchor tag with the specified URL.</p> <p>So assume you have a structure like this:</p> <pre><code>&lt;ul&gt; &lt;li&gt;&lt;a href="/apple/oranges/3"&gt;Some link&lt;/li&gt; &lt;li&gt;&lt;a href="/apple/banana/4"&gt;Another link&lt;/li&gt; &lt;/ul&gt; </code></pre> <p>And you use a selector with your parsed URL:</p> <pre><code>var parsedUrl = "/apple/orange/3"; // I've used a string here for clarity var currentAnchor = $("a[href=" + parsedUrl + "]"); </code></pre> <p>Now you have a starting point to apply your css.</p> <p>Say you want to add in your >> symbol, then:</p> <pre><code>currentAnchor.text("&gt;&gt;" + currentAnchor.text()) </code></pre> <p>Say you want to add some classes:</p> <pre><code>currentAnchor.addClass("active"); </code></pre> <p>You can also access other elements relative to this anchor with various selectors, e.g.</p> <pre><code>currentAnchor.parents("li").css("display", "block"); </code></pre> <p>So you can end up with a generic block of code instead of the giant if monster you have:</p> <pre><code>var parsedUrl = "/apple/orange/3"; // I've used a string here for clarity var currentAnchor = $("a[href=" + parsedUrl + "]"); currentAnchor.addClass("active"); currentAnchor.parents("li").css("display", "block"); </code></pre> <p>And you also wouldn't need to reference any element directly by id with this approach.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload