Search code examples
jqueryjquery-uijquery-tabs

Getting element within a known element


I am finding the selected jquery tab ui element using the following:

$("li.ui-tabs-selected").attr("id")

This might return something like:

tab_48

Within the tab_48 html tag, I have an anchor tag, so maybe

<a href="#ui-tabs-4">some content here</a>

Putting that all together, HTML might look something like this:

<li id="tab_48">
    <a href="#ui-tabs-4">
        some content here
    </a>
</li>

How do I get the href of the anchor tag, now that I can get the id of the selected tab via:

$("li.ui-tabs-selected").attr("id")

Solution

  • $("li.ui-tabs-selected a").attr("href")
    

    or

    $("li.ui-tabs-selected").find("a").attr("href")