There are 4 divs on my page and button. If you click on the div, it will switch to Class.
At the click of a button, I want all the selected areas to be selected to remain selected, but I don’t want to divs toggleClass anymore after clicking the button.
Is there any way to do this?
My code is as follows:
function submit() {
};
function choose() {
$('.options').click(function() {
$(this).toggleClass('highlighted');
});
return;
};
$(document).ready(function() {
$('body').append('<div class="options">option1</div>');
$('body').append('<div class="options">option2</div>');
$('body').append('<div class="options">option3</div>');
$('body').append('<div class="options">option4</div>');
$('body').append('<button onclick=submit()>Submit</button>');
choose();
});
I was looking for a way to stop the select () function. Creating the goOn variable and changing its value to false when clicking the button plus a bit of code below did not help.
var goOn = true;
while (goOn) {
choose();
};
Basil source
share