Reputation: 8705
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?
Upvotes: 0
Views: 77
Reputation: 4159
This should work.
selektuj_sve.on('click', function() {
$(this).text(box.is(':checked') ? 'Deselect All' : 'Select All');
box.attr('checked', !box.is(':checked'));
});
Upvotes: 3
Reputation: 36551
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...
});
Upvotes: 1
Reputation: 6463
selektuj_sve.on('click', function(){
box.attr('checked', !box.is(':checked'));
$(this).text('De-select All');
});
Upvotes: 0