How can I disable a jquery function using an if else statement.
My problem is that I have two text boxes that open onClick, they are set to toggle, but how can I set it so that if one of the boxes is open, the other one won’t open
My jquery is
$(".first1").on('click',
function () {
$('#suitsyou').toggle();
});
$(".last1").on('click',
function () {
$('#dealsandoffers').toggle()
});
It may be easier to look at my website http://www.jeremyspence.net78.net it is in the packages tab, you can see that when you click on one tab and then the other without closing the first they both open
the html is
<div id="suitsyou" style="display:none">
</div>
<div id="dealsandoffers" style="display:none">
</div>
Content was not included so not to put so much code in
A simple conditional should work:
Use classes if you need more flexibility than that. This also isn’t particularly user friendly. Seems to me like you would want to close the other and then show the one that was currently clicked.