jQuery: Changing the CSS on an element loaded with ajax?

后端 未结 3 1481
别那么骄傲
别那么骄傲 2020-12-15 12:05

I need to change the position of an element i\'m loading with ajax. I want to use .css() to change it but jQuery can\'t find the element cause it\'

3条回答
  •  没有蜡笔的小新
    2020-12-15 12:47

    If you want to edit it's CSS, you need to place it in the DOM first, then manipulate it.

    Example:

    $.ajax({
        ...
        success:function(data){
            $('
    ').appendTo('body').html(data).css('border','3px solid red'); } });

提交回复
热议问题