开发者

replacing something else after ajax request?

i have this html:

<a href="#" class="cancel" id="cancel_3'">cancel</a>

when the user clicks cancel, i want to remove the hyperlink and i want to replace this with an image i.e.

$.ajax({
        context:this,
        type: "POST",
        url: "actions/cancel.php",
        data: "id开发者_StackOverflow中文版=" + the_id,
        cache: false,
        success: function() {

            $(this).remove;
         // add image 

thanks :))


Try:

success: function() {
  $( "a#cancel_3" ).replaceWith( "<img...>" );
}

You'll have to fill in the HTML in the replaceWith function with whatever you want to replace the link with. is just a placeholder I used.


How about:

$(this).css('display', 'none').after('<img>');
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜