Reputation: 543
Below is my app code:
<li class="ui-block-e">
<a href="#login" data-transition="slide" data-role="button" data-theme="b" data-mini="true" id="UserLoginButtonP5" data-corners="false" data-shadow="false" data-iconshadow="true" data-wrapperels="span" class="ui-btn ui-btn-inline ui-mini ui-btn-up-b" data-inline="true">
<span class="ui-btn-inner">
<span class="ui-btn-text">Login</span>
</span>
</a>
</li>
jQuery replace code:
$("#UserLoginButtonP1").html("<span class='ui-btn-inner'><span class='ui-btn-text'>Logout</span></span>");
How do I replace Login to Logout text?
Upvotes: 1
Views: 349
Reputation: 19282
var test = $("#UserLoginButtonP5").html();
test = test.replace('Login', 'Logout');
$("#UserLoginButtonP5").html(test);
Working Demo on jsfiddle
Upvotes: 1
Reputation: 2893
Try this,
If you want to replace the button text, when click the button means the given below code will work.
$("#btn1").click(function(){
$(this).val("Logout");
});
In your scenario, you want to change the text of span
, so you can use span
css class name as click event like,
$(".ui-btn-text").bind('click',function(){
$(this).html("Logout");
});
(or)
you want to do this in a
click event, the given below code will work,
$("#UserLoginButtonP5").bind('click',function(){
$("#UserLoginButtonP5 .ui-btn-text").html("Logout");
//$("#UserLoginButtonP5 .ui-btn-text").text("Logout"); ('text' will be work also)
});
Upvotes: 0