$(function() {
        $("#username").val(jQuery.cookie("gusu_loginName"));
        });
username为input的ID,输出结果为null,如何转换成“ ”。在线等。急

解决方案 »

  1.   

    $(function() {
        var loginName = jQuery.cookie("gusu_loginName");
        if (loginName == null) loginName = '';
        $("#username").val(loginName);
    });
      

  2.   

    呵呵!我也写出来了。和你这个差不多
     $(function() {
                if (jQuery.cookie("gusu_loginName") == null) {
                    $("#username").val("");
                } else {
                    $("#username").val(jQuery.cookie("gusu_loginName"));
                }
            });