所以我有一系列按钮,用于关闭/打开一周中每一天的所有复选框,目前看起来真的很乱,所以我想把所有按钮变成一个下拉选择字段,在更改例如,星期一的选项将运行星期一 jquery 以隐藏所有星期一复选框。
这是html
<input type='submit' name='submit_performances' value='update all'>
<input type='button' id='select-all-toggle' name='select-all-toggle' value='Hide/Show all Performances'>
<input type='button' id='select-all-toggle-monday' name='select-all-toggle-monday' value='Hide/Show all Monday Performances'>
<input type='button' id='select-all-toggle-tuesday' name='select-all-toggle-tuesday' value='Hide/Show all Tuesday Performances'>
<input type='button' id='select-all-toggle-wednesday' name='select-all-toggle-wednesday' value='Hide/Show all Wednesday Performances'>
<input type='button' id='select-all-toggle-thursday' name='select-all-toggle-thursday' value='Hide/Show all Thursday Performances'>
<input type='button' id='select-all-toggle-friday' name='select-all-toggle-friday' value='Hide/Show all Friday Performances'>
<input type='button' id='select-all-toggle-saturday' name='select-all-toggle-saturday' value='Hide/Show all Saturday Performances'>
<input type='button' id='select-all-toggle-sunday' name='select-all-toggle-sunday' value='Hide/Show all Sunday Performances'>
</form>
这是jQuery
<script>
$(document).ready(function() {
$('#select-all-toggle').toggle(
function() {
$('.select-all-identifier').prop('checked', true);
},
function() {
$('.select-all-identifier').prop('checked', false);
}
);
});
$(document).ready(function() {
$('#select-all-toggle-monday').toggle(
function() {
$('.monday').prop('checked', true);
},
function() {
$('.monday').prop('checked', false);
}
);
});
$(document).ready(function() {
$('#select-all-toggle-tuesday').toggle(
function() {
$('.tuesday').prop('checked', true);
},
function() {
$('.tuesday').prop('checked', false);
}
);
});
$(document).ready(function() {
$('#select-all-toggle-wednesday').toggle(
function() {
$('.wednesday').prop('checked', true);
},
function() {
$('.wednesday').prop('checked', false);
}
);
});
$(document).ready(function() {
$('#select-all-toggle-thursday').toggle(
function() {
$('.thursday').prop('checked', true);
},
function() {
$('.thursday').prop('checked', false);
}
);
});
$(document).ready(function() {
$('#select-all-toggle-friday').toggle(
function() {
$('.friday').prop('checked', true);
},
function() {
$('.friday').prop('checked', false);
}
);
});
$(document).ready(function() {
$('#select-all-toggle-saturday').toggle(
function() {
$('.saturday').prop('checked', true);
},
function() {
$('.saturday').prop('checked', false);
}
);
});
$(document).ready(function() {
$('#select-all-toggle-sunday').toggle(
function() {
$('.sunday').prop('checked', true);
},
function() {
$('.sunday').prop('checked', false);
}
);
});
</script>
任何帮助将不胜感激。
谢谢,