Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8419359
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T02:35:14+00:00 2026-06-10T02:35:14+00:00

I have several a tags being generated dynamically in a enterprise application like below

  • 0

I have several a tags being generated dynamically in a enterprise application like below

<a href='JavaScript:SWESubmitForm(document.SWEForm1_0,s_1,"s_1_1_1_0","1-SXPINW")' onclick='Edit_SList__0__Control__Renew_SPO__onclick(null, "s_1_1_1_0")'  tabindex=2997  id='s_1_1_1_0'>Renew PO</a>
<a href='JavaScript:SWESubmitForm(document.SWEForm1_0,s_2,"s_1_1_4_0","1-SXP9NW")' onclick='Edit_SList__0__Control__XRXAddFunds__onclick(null, "s_1_1_4_0")'  tabindex=2997  id='s_1_1_4_0'>Add Funds</a>

I have following jQuery code to extract unique value identifying the record from tag

var href = $('a[href*="SWESubmitForm"]').attr('href');
var rowId = "";
    if( href != ""){
        hrefAr =  href.split('","');
        rowId = hrefAr[hrefAr.length - 1];
        rowId = rowId.substr(0,(rowId.length - 2));
    }

The above code gives me the value 1-SXPINW
but I need to get value 1-SXP9NW (2nd link and there could several links on one page).
I need to add filter for the text basically retrieve only the value for the link with particular text such as “Add Funds”.

I know it is possible to use each and add if statement to check text but I would like to do it through filter.

Please help!!!

EDIT:

I think I didn’t explain the problem properly. I need to setup filter in such a way that

if (text within a tag == "Add Funds") then get the value of ID within href attribute

I would like setup my filter based on the text() within a tag. I hope it clarifies the problem a bit better.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T02:35:16+00:00Added an answer on June 10, 2026 at 2:35 am

    Select the element you want.. If there is two of them just use .eq() since it returns all elements that match your selector- .eq will return a jquery object

    var href = $('a[href*="SWESubmitForm"]').eq(1).attr('href'); // <-
    

    or convert it to dom element

    var href = $('a[href*="SWESubmitForm"]')[1].href; 
    

    Also since you have an ID you can just select the one you want with the ID selector

    var href = $('#s_1_1_4_0').attr('href');
    

    Or if there’s too many and you need to find the one with 9NW.. just use indexOf in your check

    $('a[href*="SWESubmitForm"]').each(function(){
         var rowId = ""; 
         if(this.href.indexOf('1-SXP9NW') > -1){ // <-- use indexOf to see if href contains the string                  
             hrefAr =  this.href.split('","');
             rowId = hrefAr[hrefAr.length - 1];
             rowId = rowId.substr(0,(rowId.length - 2));    
         }
    });
    

    With filter function

    var href = $('a[href*="SWESubmitForm"]').filter(function(){
             return this.href.indexOf('1-SXP9NW') > -1;
    }).attr('href');   
    

    After all this.. Why don’t you just use this selector?

    $('a[href*="1-SXP9NW"]')
    

    EDIT:

    If Add Funds is static.. then use the :contains() selector

    var href = $('a:contains("Add Funds")').attr('href');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have several a tags as shown below on a dynamically generated page <a
Let's say we have a grails web application exposing several resources. tags urls users
I have a scenario where an item is being tagged with several tags, some
I have several tags in my page that look like this: <em class=itemx item###
I have several anchor tags in a text, Input: <a href=http://stackoverflow.com >Take me to
I have several tags with the class i11 all with child tags of class
I have several select tags on a page and I am grouping them using
I have several popovers (on a tags) that make ajax calls to populate their
Rails and MySQL: I have a table with several boolean columns representing tags. I
I have several Div tags on a page which are dynamic, i.e. depending on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.