I know this seems like a tired old question, but despite hours on this and reading previous posts, still no luck. Individual countries tick and highlight nicely, but I can't get the select all/untick all buttons to do anything. Anyone any ideas? http://ift.tt/2hijuOm
<input type="button" id="CountrySelectAll_ID_ws" value ='Tick all' />
<input type="button" id="CountrySelectNone_ID_ws" value ='UNtick' />
<div class="multiselect">
<br>
<label><input type="checkbox" name="option[]" value="1" />Germany</label>
<label><input type="checkbox" name="option[]" value="2" />France</label>
<label><input type="checkbox" name="option[]" value="7" />Spain</label>
</div>
jQuery.fn.multiselect = function() {
$(this).each(function() {
var checkboxes = $(this).find("input:checkbox");
checkboxes.each(function() {
var checkbox = $(this);
// Highlight pre-selected checkboxes
if (checkbox.attr("checked"))
checkbox.parent().addClass("col-on");
// Highlight checkboxes that the user selects
checkbox.click(function() {
if (checkbox.attr("checked"))
checkbox.parent().addClass("col-on");
else
checkbox.parent().removeClass("col-on");
alert$("option:selected");
});
});
});
};
$(function() {
$(".multiselect").multiselect();
});
$(function() {
$("#CountrySelectAll_ID_ws").on('click', function()
$('.multiselect').find("input:checkbox").prop('checked',true);
})
});
$(function() {
$("#CountrySelectNone_ID_ws").on('click', function()
{
$('.multiselect').find("input:checkbox").prop('checked',false);
})
});
Aucun commentaire:
Enregistrer un commentaire