This is a migrated thread and some comments may be shown as answers.

Toggle text on button (without changing page)

2 Answers 380 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Jan-Dirk
Top achievements
Rank 1
Jan-Dirk asked on 22 Jan 2013, 03:55 PM
I want to change the text on the button without making a page transition. The initial text is 'Show', but when I click the button it should be change to 'hide'.
I have a button in html like this:
<a href="" id="btnShowHide" data-role="button" style="background-color: rgb(135, 196, 66);">Show</a></div>


I have this function to toggle the text:
$("#btnShowHid").kendoMobileButton({
                click: function (e) {
                    var element = document.getElementById('btnShowHide');
                    if (element.innerText === "Hide") {
                        window.localStorage.removeItem(followProjectID);
                        element.innerText = "Show"
                    }
                    else {
                        window.localStorage.setItem(followProjectID, (followProjectTitle + "|" + followProjectImageUrl + "|" + followProjectDescription));
                        element.innerText = "Hide"
                    }
                    // $("#btnShowHid").kendoMobileButton();
                    e.preventDefault();
                }
            });



However,  the text doesn't change

2 Answers, 1 is accepted

Sort by
0
Kristian D. Dimitrov
Telerik team
answered on 23 Jan 2013, 07:38 AM
Hi Jan-Dirk,

 I think the problem is just a typo. I changed the first selector from "$("btnShowHid")" to "$("btnShowHide")"  and it worked like a charm.

Regards,
Kristian D. Dimitrov
the Telerik team

Share feedback and vote for features on our Feedback Portal.
Want some Kendo UI online training - head over to Pluralsight.
0
Jan-Dirk
Top achievements
Rank 1
answered on 24 Jan 2013, 03:56 PM
Wow, great find! Seems to work now
Tags
General Discussions
Asked by
Jan-Dirk
Top achievements
Rank 1
Answers by
Kristian D. Dimitrov
Telerik team
Jan-Dirk
Top achievements
Rank 1
Share this question
or