Note that there are some explanatory texts on larger screens.

plurals
  1. POJQuery - Perform matching based on text inside <A> Tags
    primarykey
    data
    text
    <p>I have had a look at; <a href="https://stackoverflow.com/questions/4189124/jquery-extract-url-from-text">Jquery Extract URL from Text</a> and <a href="https://stackoverflow.com/questions/1956184/jquery-match-variable-interpolation-complex-regexes">jquery match() variable interpolation - complex regexes</a> but I'm still a bit lost.</p> <p>The problem; I have a page that contains a drop down menu along the top, inside the drop down is the name of an item which I can click on to view that item. The URL of the item is unrelated to the name, it is a unique ID.</p> <p>Example code of dropdown;</p> <pre><code> &lt;div class="innerMenuWrapper"&gt; &lt;li class="hasSubMenu sfhover"&gt; &lt;a href="javascript:void(0);" tabindex="-1" class="menuItemLink"&gt;Items&lt;/a&gt; &lt;span class="splIcon splIcon-triangle-4-e dropDown"&gt;Submenu&lt;/span&gt; &lt;div class="outerMenuWrapper splShadow" style="left: 160px; display: none; "&gt; &lt;ul&gt; &lt;div class="innerMenuWrapper"&gt; &lt;li class=""&gt; &lt;a href="/en-US/app/Items/itemahdwhidwbow" tabindex="-1" class="menuItemLink"&gt;item.one&lt;/a&gt; &lt;/li&gt; &lt;li class=""&gt; &lt;a href="/en-US/app/Items/itemfhfaogsgs" tabindex="-1" class="menuItemLink"&gt;item.two&lt;/a&gt; &lt;/li&gt;&lt;/div&gt;&lt;/ul&gt;&lt;/div&gt;&lt;/li&gt;&lt;/div&gt; </code></pre> <p>This is all generated externally and managed by the actual web service itself. On the page itself is a table generated from a dataset. I have generated the data with no problem and presentation is fine as-well. What I want to do is to pull the URL from the HREF above and to wrap the same item in the table on the main page.</p> <p>E.g. I have a table of 3 columns, Items, Item contents, Item price etc. I want to wrap each Item with its associated URL from the above.</p> <p>So to take item.one as an example, that is the name it has in the drop down and has the URL, <code>/en-US/app/Items/itemahdwhidwbow</code>. Inside the data itself I have this code to select each first cell of the table and wrap the contents with a link (part of a larger code-set);</p> <pre><code>if (tr.find("td:nth-child(1)")) { tr.find("td:nth-child(1)").wrapInner(function() { var link = $('&lt;a/&gt;'); link.attr('href', 'US/app/Items/itemahdwhidwbow'); link.text($(this)); return link; }); } </code></pre> <p>Obviously at the moment the URL is static. What I really need is a way to pull the URL from the associated link in the drop down on the same page. The name in the first table cell will always match the name in the drop down list, is there a simple way for me to do this? What I have read so far points towards regex use but in this case I am looking for the contents of one part of the code to match something further down the page.</p> <p>EDIT:</p> <p>So for example, item.one has the text "item.one". "item.one" is also in the table, I want the "item.one" in the table to have the same link as in the drop down. If I could get to the text inside the anchor then I could just do a match against the text in the table</p>
    singulars
    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.
 

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