有没有办法自定义输出到输入 (type range) 旁边的内容,以显示输入的值?我希望它能显示值 + %。
目前我尝试给输入框添加一个自定义类,并获取其 <output>
标签,然后像这样操纵其内部文本:
$(document).on('input', 'input', function () {
$(".customSwal output").text( $(".customSwal").val() + " %" )
});
没有特别成功的结果
$(document).ready(function(){
Swal.fire({
icon: 'question',
showCancelButton:'true',
cancelButtonColor: '#d33',
title: 'Test',
text: 'Test',
input: 'range',
width: '25rem',
inputAttributes: {
min: 0,
max: 100,
step: 1,
},
inputValue: 0,
customClass: {
input: 'customSwal',
}
})
});
//$(document).on('input', 'input', function () {
//$(".customSwal output").text( $(".customSwal").val() + " %" )
//});
<!DOCTYPE html>
<html>
<head>
<script src="https://code.jquery.com/jquery-3.6.0.js"></script>
<script src="//cdn.jsdelivr.net/npm/sweetalert2@10"></script>
</head>
<body>
</body>
</html>