javascript – 在sweetAlert中输入文本

前端之家收集整理的这篇文章主要介绍了javascript – 在sweetAlert中输入文本前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在使用自定义版本的 sweetalert来询问我的用户输入.我已经设法使一切工作,但有一个奇怪的行为,为了能够在输入框中输入文本,你必须先点击屏幕:
swal({
    title: "Aggiornamento profilo",text: '<br /><form method="post" id="taxcode-update" name="taxcodeUpdate"><input id="admin-tax-code" minlength="3" class="form-control wedding-input-text wizard-input-pad" type="text" name="taxCode" placeholder="Codice fiscale"></form>',type: "warning",showCancelButton: false,confirmButtonText: "Aggiorna il mio profilo",cloSEOnConfirm: false
},function () {
    swal("Deleted!","Your imaginary file has been deleted.","success");
});

工作实例:https://jsfiddle.net/fvkppx06/

解决方法

swal({
  title: "An input!",text: "Write something interesting:",type: "input",showCancelButton: true,cloSEOnConfirm: false,animation: "slide-from-top",inputPlaceholder: "Write something"
},function(inputValue){
  if (inputValue === false) return false;

  if (inputValue === "") {
    swal.showInputError("You need to write something!");
    return false
  }

  swal("Nice!","You wrote: " + inputValue,"success");
});
原文链接:https://www.f2er.com/js/156244.html

猜你在找的JavaScript相关文章