0

I have code which check all the checkboxes and add or remove checked status (this part is working). I need to change text when this function is clicked from "Select All" to "De-select All". Button to select all:

<a class="zute_strane_izmena_selektuj_sve">Select All</a>

jQuery code:

var selektuj_sve = $('.zute_strane_izmena_selektuj_sve'),
slike = $('.zuta_strana_trenutne_slike'),
box = slike.find(':checkbox');

selektuj_sve.on('click', function(){
    box.attr('checked', !box.is(':checked'));
});

What I need to do?

3 Answers 3

3

This should work.

selektuj_sve.on('click', function() {
    $(this).text(box.is(':checked') ? 'Deselect All' : 'Select All');
    box.attr('checked', !box.is(':checked'));
});
Sign up to request clarification or add additional context in comments.

Comments

1

trt this:

selektuj_sve.on('click', function(){
    box.attr('checked', !box.is(':checked'));
    $(this).html('De-select All'); // u can use text() instead of html().. this changes the  text inside to  deselectAll...
}); 

Comments

0
selektuj_sve.on('click', function(){
    box.attr('checked', !box.is(':checked'));
    $(this).text('De-select All');
});

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.