jquery实现字体选择

<head runat="server">
<script src="/static/js/jquery-1.2.6.js" type="text/javascript"></script>
<style type="text/css">
.tl_common {}
.tl_blue { color:#0000ff;}
.tl_red {color:#ff0000;}
.tl_boldblue {color:#0000ff;font-weight:bolder;}
.tl_boldred {color:#ff0000;font-weight:bolder;}
</style>
<body>
<select id="titlestyle" name="titlestyle" onchange="$('#titleprev').removeClass().addClass($(this).val());"></select>&nbsp;&nbsp;[<span id="titleprev">预览资讯标题样式</span>]
</body>
<script type="text/javascript">
 $(function() {
        initcolorpicker($("#titlestyle"), '资讯标题资讯标题'); 
        });

function initcolorpicker(selectinst,title) {
        var colorarr = { 'tl_common': '普通', 'tl_blue': '蓝色', 'tl_red': '红色', 'tl_boldblue': '蓝色粗体' , 'tl_boldred': '红色粗体'};
        $.each(colorarr, function(i, val) {
        var color = i.toString();
        var option = document.createElement("option");
        option.value = color;
        var textnode = document.createTextNode(decodeURIComponent(val));
        option.appendChild(textnode);
        selectinst.append(option);//这个函数是对,titlestyle赋值
    });
    return selectinst;
}

</script>
只是为了方便记忆!

posted @ 2008-10-20 10:56  悟〈--觉  阅读(498)  评论(0编辑  收藏  举报