代码之家  ›  专栏  ›  技术社区  ›  TheNone Nabster

用javascript格式化标题

  •  0
  • TheNone Nabster  · 技术社区  · 15 年前

    我将此脚本用于表单标题:

    $(document).ready(function(){
        $('.add-news').each( function () {
            $(this).val($(this).attr('defaultValue'));
            $(this).css({'color':'#686868' ,  'font-size':'11px', 'font-weight':'bold'});
        });
        $('.add-news').focus(function(){
            if ( $(this).val() == $(this).attr('defaultValue') ){
                $(this).val('');
                $(this).css({'color':'#686868' , 'font-size':'11px' ,'font-weight':'bold'});
            }
        });
        $('.add-news').blur(function(){
            if ($(this).val() == '' ){
                $(this).val($(this).attr('defaultValue'));
                $(this).css({'color':'#686868' ,  'font-size':'11px', 'font-weight':'bold'});
            }
        });
    
    });
    

    The example is here

    提前谢谢

    2 回复  |  直到 15 年前
        1
  •  3
  •   RoToRa    15 年前

    在删除明显的错误(“defaultue”而不是“defaultValue”,以及 css

    http://jsfiddle.net/TY2sf/

        2
  •  0
  •   goenning    15 年前