Jeff.Clark
Jeff.Clark

Reputation: 611

Changing anchor tag text while using PhoneGap and jQuery

As a preface, I am using PhoneGap. When I click on a Category Title, I have taken that title and set it in sessionStorage. Now, I want to set the "back" button of a new PhoneGap page (which displays some information contained in that category) to that Category Title. The HTML code is shown below. To be specific, I want to change the text of the "a" element within the "header" element.

I guess a part of my question is, does the fact that I am using PhoneGap change how I can access the anchor tag? I've been trying to set the back button text right after the Category has been selected/clicked on. I have tried multiple things like:

$("adviceBodyNavbarHeader a").text(sessionStorage.getItem("catTitle"));

but I can't quite get it working, and it is getting quite frustrating =/

<div data-role="view" id="adviceBody" data-title="Advice Body" data-show="GetAdviceBody" data-transition="slide">
    <header data-role="header" id="adviceBodyNavbarHeader">
        <div class="navHeader">
            <a class="nav-button" data-view="adviceTitles" data-align="left">Back</a>
            <span id="adviceTitle" class="navTitle"></span>
        </div>
    </header>
    <ul id="advice-body" data-role="listview">
    </ul>
</div>

Upvotes: 0

Views: 434

Answers (1)

malifa
malifa

Reputation: 8165

Your selector is wrong. You try to select a html element called adviceBodyNavbarHeader.

What you want to do is this: $('#adviceBodyNavbarHeader').text(sessionStorage.getItem("catTitle"));

Hope it helps.

Edited my post due to late brain inactivity.

Upvotes: 2

Related Questions