Reputation: 353
I'm using this script to execute two actions.
It's a toggle for #mobileJ
and #botaojs
but they aren't executing at the same time; I would like to make both actions happen together.
$(document).ready(function(){
$("#namala").click(function(){
$("#mobileJ").toggle(function () {
$("#botaojs").toggleClass("toggleclass");
});
});
});
Upvotes: 1
Views: 1215
Reputation: 5224
Don't put the second action in a callback
<!-- Script Jquery -->
<script>
$(document).ready(function(){
$("#namala").click(function(){
$("#botaojs").toggleClass("toggleclass");
$("#mobileJ").toggle();
});
});
</script>
Upvotes: 0
Reputation: 218808
The callback function for .toggle()
happens after it's complete, not at the same time. In order for both to happen simultaneously (at least observed simultaneously, though there's likely some millisecond-delay), don't use the callback. Just execute them both:
$("#mobileJ").toggle();
$("#botaojs").toggleClass("toggleclass");
Upvotes: 3