jQuery find last input and append

前端 未结 3 918
一生所求
一生所求 2021-01-23 04:03

I am trying to append an image after the last input field in a div, any ideas as to why this won\'t work?

$(\'

        
相关标签:
3条回答
  • 2021-01-23 04:50

    Try this:

    $('<img src="img/loading.gif" id="loading_img" />').appendTo('#formid-here input:last'));
    
    0 讨论(0)
  • 2021-01-23 04:55

    You must use the insertAfter function:

    $('<img src="img/loading.gif" id="loading_img" />').insertAfter($("form").find('input:last'));
    

    The append function adds the image INTO the input with insertAfter you insert the image AFTER the input.

    0 讨论(0)
  • 2021-01-23 04:59
    $("<img/>", {
      src:  "img/loading.gif",
      id:   "loading_img"
    }).insertAfter($("form").find("input:last"));
    
    0 讨论(0)
提交回复
热议问题