get href from a jquery variable

mgmhicks
mgmhicks used Ask the Experts™
on
I have a var tab that consists of this on google console

<li class>
<a href="#App1" role="tab" data-toggle="tab" aria-expanded="false">Applicant 1></a>
</li>

my question is how can I get the href (#App1) to a string, I have 3 of these tabs and I need the name of the href.

thank you
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2018
Distinguished Expert 2018
Commented:
To get the href in general you'd use:

$('li a').attr('href');

You'll need a way to indentify which hrefs you need to get, and you haven't given enough info for us to show that.

You'll probably need to give us some more info for specific an answer, and maybe show more of your code.

Author

Commented:
Hi, I tried then $(tab li a).attr('href') and it came back undefined.  Remember tab object is already
<li class>
 <a href="#App1" role="tab" data-toggle="tab" aria-expanded="false">Applicant 1></a>
 </li>

It comes from the partial code

 $('#AppWizard').bootstrapWizard({

            onTabClick: function (tab, navigation, index) {
                var myform = $(this).html;

etc...
Most Valuable Expert 2018
Distinguished Expert 2018

Commented:
OK.

$(tab li a).attr('href') is not a valid selected. First of all, your selector should be in quotes, and secondly, tab is not a valid html element, so it won't work.

It's possible that your script is changing the HTML, so that the href is no longer in an LI.

Like I said, we'll need to see the code - preferably in a working page. jQuery works on the generated HTML, so that's what we'd need to see.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial