首页 > 解决方案 > 获取动态添加选项的选项值

问题描述

这里是为选择标签创建选项的代码我想要更改选项时的选项值,我已经尝试了几乎所有可以放入其中的东西,但没有运气,我什至看不到选项中的“选定”属性,我添加了html结构和代码的图片。请分享您对此的看法。谢谢。这是小提琴 - https://jsfiddle.net/pa8e47nx/1/

在此处输入图像描述

Product.Config.prototype.loadOptions = function() {
    this.settings.each(function(element){
        element.disabled = false;
        element.options[0] = new Option(this.config.chooseText, '');
        var attributeId = element.id.replace(/[a-z]*/, '');
        var options = this.getAttributeOptions(attributeId);
        if(options) {
            var index = 1;
            for(var i=0;i<options.length;i++){
                options[i].allowedProducts = options[i].products.clone();
                element.options[index] = new Option(this.getOptionLabel(options[i], options[i].price), options[i].id);
                if (typeof options[i].price != 'undefined') {
                    element.options[index].setAttribute('price', options[i].price);
                }
                element.options[index].setAttribute('data-label', options[i].label.toLowerCase());
                element.options[index].config = options[i];
                index++;
            }
        }
        this.reloadOptionLabels(element);
    }.bind(this));
},

标签: javascripthtmljquerymagento

解决方案


推荐阅读