onChange in YUI

做~自己de王妃 提交于 2019-12-22 08:35:42

问题


How we can write code for onChange function in YUI 2 and YUI3.

jQuery(':input[type=radio]').change(function(){

  var aType=jQuery(this).val();
  var numT= aType==1 ? "3" : "6" ;
  var aWidth=aType==1 ? "330px" : "660px" ;

});

回答1:


In YUI 3

Y.all('input[type=radio]').each(function (node) {
    node.on('change', function () {
        var val = this.get('value');
        ...
    });
});

// or
Y.all('input[type=radio]').on('change', function (e) {
    var val = e.currentTarget.get('value');
    ...
});

In YUI 2.9 (which is no longer under active development; use YUI 3)

// typical implementations alias Event or Event.on and
// Selector.query to shorter names
YAHOO.util.Event.on(
    YAHOO.util.Selector.query('input[type=radio]'), 'change', function (e) {
        var val = this.value;
    ...
});


来源:https://stackoverflow.com/questions/7039787/onchange-in-yui

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!