I have an issue with jquery mobile and a button text switch.
The button text should change everytime sie button is clicked. It is working one time only. I click the button, the text and backgound changes, the second time I click it nothing happens. Here ist my code:
Button declaration:
<div data-role="header">
<div data-role="navbar">
<ul>
<li><a href="#" id="lock" class="lockaction" >Lock</a></li>
</ul>
</div>
</div>
And here the function I have:
$(".lockaction").click(function(e) {
if (e.target.id == "lock" ) {
document.getElementById("lock").text = "Unlock";
$(this).css("background-color", "red");
}
else {
document.getElementById("lock").text = "Lock";
}
postupdate();
});
Maybe someone can help me with it.