How to replace href inside of <li> using jQuery

1.3k views Asked by At

I am trying to convert a piece of code that is coming out out of a content holder. I need to modify the href within the <LI> tag using jQuery.

Currently the code looks like this:

<li id="ctl01_Auxiliary_Auxiliary_rptWrapper_Auxiliary_rptWrapper_rpt_ctl01_NavigationListItem" class="NavigationListItem">
    <a id="ctl01_Auxiliary_Auxiliary_rptWrapper_Auxiliary_rptWrapper_rpt_ctl01_NavigationLink" class="NavigationLink" href="/Public/Cart/Core/cart/MyCart.aspx?hkey=70255604-fa6d-48b6-874e-ddb636d4f3ed">
        <span class="nav-text">
        Cart
        <span class="cartFull">
        <span class="cartLeft cartSprite"></span>
        <span class="cartCenter cartSprite">
        <span>1</span>
        </span>
        <span class="cartRight cartSprite"></span>
        </span>
        </span>
    </a>
</li>

And I need to modify it to look like this:

<li id="ctl01_Auxiliary_Auxiliary_rptWrapper_Auxiliary_rptWrapper_rpt_ctl01_NavigationListItem" class="NavigationListItem">
    <a id="ctl01_Auxiliary_Auxiliary_rptWrapper_Auxiliary_rptWrapper_rpt_ctl01_NavigationLink" class="NavigationLink" href="/Public/Cart">
        <span class="nav-text">
        Cart
        <span class="cartFull">
        <span class="cartLeft cartSprite"></span>
        <span class="cartCenter cartSprite">
        <span>1</span>
        </span>
        <span class="cartRight cartSprite"></span>
        </span>
        </span>
    </a>
</li>

I tried all sorts of recommendations from on this site but none have worked so far.

1

There are 1 answers

4
Max Flex On BEST ANSWER
 $("li #ctl01_Auxiliary_Auxiliary_rptWrapper_Auxiliary_rptWrapper_rpt_ctl01_Navigat‌​ion‌​Link").attr("href", "/Public/Cart")