【问题标题】:onchange event for attribute in jquery [duplicate]jquery中属性的onchange事件[重复]
【发布时间】:2015-07-13 08:57:37
【问题描述】:

html:

<input class="spinner1 ui-spinner-input" id="q1" name="value" value="1" min="1" aria-valuemin="1" aria-valuenow="5" autocomplete="off" role="spinbutton">

如何添加更改aria-valuenow 值的事件?

【问题讨论】:

标签: jquery html


【解决方案1】:

没有所有浏览器都支持的本地方式来执行此操作,您可以查看Mutation_Events,但它的功能并不完整。

但是,您可以在更改自定义属性的项目上触发自定义事件,并监听此事件以进行必要的更改:

$(document).on('custom-attribute-changes', function() {
    // listen to the data change and do what you need
  });

  $('#button').click(function() {

// trigger this event on any certain change that shall edit its value
    $(document).trigger('custom-attribute-changes');
  });

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-04-20
    • 1970-01-01
    • 1970-01-01
    • 2017-11-17
    • 1970-01-01
    • 1970-01-01
    • 2020-11-17
    • 1970-01-01
    相关资源
    最近更新 更多