我无法解决的问题是“if”语句似乎没有以正确的方式工作,它向后工作?
$(document).ready(function() {
$(".clearAllBtn").click(function() {
var txt = $(this).html();
if ($(this).html() === 'Clear all') {
$(".radioFit").each(function() {
$(this).prop('checked', false);
});
$(this).html("Select all")
} else {
$(".radioFit").each(function() {
$(this).prop('checked', true);
});
$(this).html("Clear all")
}
});
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>