开发者

Please help with prependTo & replace javascript code!

<script type="text/javascript">
$(document).ready(function() {
    $('#divID').each(function() {
        var $select = $('<select id="dropdown" onchange="location = this.options[this.selectedIndex].value;" />');
        $(this).find('a').each(function() {
            var $option = $('<option />');
            $option.attr('value', $(this).attr('href')).html($(this).html());
            $select.append($option);
        });
 开发者_StackOverflow中文版       $(this).replaceWith($select);
    });
    $('<option selected="selected" value="#">Select Option</option>').prependTo('#dropdown');
});
</script>

Everything works great EXCEPT the prepended option selected="selected" doesn't work in IE.


try this

$('<option value="#">Select Option</option>').attr('selected', 'selected').prependTo('#dropdown');
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜