开发者

css() with appendTo() is not applicable

 $('#item').click(function()  {

        $.ajax({
           url: 'server.php',
           type: 'POST',
           data : {temp :开发者_JAVA技巧 'aValue'},
           success: function(data) {
           $(data).css('color', 'red').appendTo('#item');
         }    
       });
     });

The problem is here :

       $(data).css('color', 'red').appendTo('#item');

while it does takes the data and works well with the appendTo() the css part is not applicable


Instead of

$(data).css('color', 'red').appendTo('#item');

try

$('<span/>').text(data).css('color', 'red').appendTo('#item');


Because data is a string, not an html element, thus why it's not css'd.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜