【发布时间】:2021-04-22 23:51:19
【问题描述】:
有没有办法自定义输入(类型范围)旁边的输出,显示输入的值? 我希望它显示值 + %。
到目前为止,我尝试的是给输入一个 customclass,然后获取它的 <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>
【问题讨论】:
标签: javascript jquery sweetalert2