Reputation: 1054
I have:
<a id = "button" style="display:inline"></a>
<a id = "buttonPressed" style="display:none"></a>
And I'm using
$('#button, #buttonPressed').click(function(event) {
$('#button, #buttonPressed').toggle();
//Do other stuff
})
The "display:inline" button is getting changed to "display:none" as desired, but the "display:none" button is changing to style="" instead of the desired "display:inline".
How do I address this?
Upvotes: 0
Views: 3082
Reputation: 144699
you can try toggleClass()
:
.hidden {
display: none
}
<a id="button">click1</a>
<a id="buttonPressed" class="hidden">click2</a>
$('#button, #buttonPressed').click(function(event) {
$('#button, #buttonPressed').toggleClass('hidden');
})
Upvotes: 0
Reputation: 1089
This works fine in a jsfiddle
So maybe there is some other conflicting code on your page?
Upvotes: 0
Reputation: 86124
Add a class to those tags. Create a css rule that enforces the inline display in the rule.
Upvotes: 1