0

尝试在单击“添加里程并打开它”后在此处的表单上实现“下拉​​”效果

它似乎只发生在第一次加载时,如果您随时刷新或返回页面,该死的东西会变成一个丑陋的正常非 jquery 下拉菜单。我假设它是因为我使用 javascript 来填充我的选择(下拉)。任何帮助将不胜感激......`

.js

// Create select element with options.
function makeRunRecord() {
    var formTag = document.getElementsByTagName('form'),
        selectList = ge('select'),
        makeSelect = document.createElement('select');
        makeSelect.setAttribute("id", "styles");
    makeSelect.setAttribute("name", "styles");
        makeSelect.setAttribute("class", "required select");
        makeSelect.setAttribute("data-native-menu", "false");
        var makePlace = document.createElement('option');
    makePlace.setAttribute("data-placeholder", "true");
    makePlace.setAttribute("value", "");
    makeSelect.appendChild(makePlace);
    for (var i=0, j=runningStyles.length; i<j; i++) {
        var makeOption = document.createElement('option');
        var optText = runningStyles[i];
        makeOption.setAttribute("value", optText);
        makeOption.innerHTML = optText;
        makeSelect.appendChild(makeOption);
    }
    selectList.appendChild(makeSelect);
};


// Call Functions

makeRunRecord();

}); .html

                   <li><div id="select"><label for="rStyle">Choose Run Style*</label></div>
4

1 回答 1

1

在页面加载后尝试运行该函数:

window.onload = function() {
    makeRunRecord();
}
于 2012-10-28T14:14:26.973 回答