【问题标题】:Change button attribute on click before link fires在链接触发之前单击更改按钮属性
【发布时间】:2012-08-03 00:30:53
【问题描述】:

我在我的网站上使用 Dwolla 平台。 我想在单击时将按钮的数据量属性更改为另一个文本字段中的值。但是,当 Dwolla 网站加载时,它会提示我支付原始的默认金额,所以我认为我的属性修改没有发生。

<script type='text/javascript'>
$('.dwolla_button').click(function(){
alert($('#id_support_amount').val());
$('.dwolla_button').attr('data-amount', $('#id_support_amount').val());
});
</script>

我正在使用来自 Dwolla 的压缩 javascript,它会在单击按钮时触发请求,因此我最终可能不得不询问他们/在其中进行挖掘。

在链接触发之前我通常如何更改属性?

【问题讨论】:

  • 哇,我也有同样的问题,似乎不太可能,很高兴我找到了这个链接!

标签: jquery html dwolla


【解决方案1】:

要在实际点击之前做一些事情,你应该使用mousedown 处理程序。

试试这样的:

$(document).on("mousedown",".dwolla_button", function(){ $(this).attr('data-amount', $('#id_support_amount').val());
});

或查看我的工作示例http://jsfiddle.net/ZMb3E/1/

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-02-01
    • 2012-04-24
    • 2023-03-13
    • 1970-01-01
    • 2014-01-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多