【问题标题】:If radio is checked then show a message action如果选中收音机,则显示消息操作
【发布时间】:2020-12-28 13:03:04
【问题描述】:

我有一个 HTML 输入单选

<input class="payment_processor_gocardless crm-form-radio" value="5" type="radio" id="QFID_5_payment_processor_id" name="payment_processor_id">

通常不选择收音机。 我想做的是,每当我点击那个收音机时,我都希望通过 sweetalert 显示一条消息。这是我的代码:

$('input[name=payment_processor_id]”]’).click(function()  {
    if (($("input[name=payment_processor_id]").attr("value")=="5") ) {  
          Swal.fire({
sweetalert message goes here
        });
  }
});

Sweetalert 在其他领域也有作用,所以这不是我关心的问题。选择单选按钮时我无法触发它。任何帮助,将不胜感激。谢谢

【问题讨论】:

  • $('input[name=payment_processor_id]”]’) 无效,添加 " 或删除它,你也有 2x ] 并且只有 1 [
  • 糟糕!忽略了它。非常感谢

标签: jquery radio-button sweetalert2


【解决方案1】:

你做了一些语义错误,你的代码做了修改。

$('input[name="payment_processor_id"]').click(function()  {
    if (($('input[name="payment_processor_id"]').attr("value")=="5") ) {  
          Swal.fire({
              sweetalert message goes here
        });
  }
});

【讨论】:

    猜你喜欢
    • 2015-10-15
    • 1970-01-01
    • 1970-01-01
    • 2014-06-03
    • 1970-01-01
    • 2012-11-13
    • 1970-01-01
    • 2013-12-09
    • 2017-09-28
    相关资源
    最近更新 更多