Getting jQuery-inserted DOM elements without requerying for element after insertion

后端 未结 3 922
北恋
北恋 2021-01-18 09:05

Assuming I insert anything in my DOM with jQuery, like so:

$(\'#someselector\').prepend(\'\');

3条回答
  •  爱一瞬间的悲伤
    2021-01-18 09:25

    Solution without creating a jQuery object before and without having an Id:

    var $img = $('#someselector')
                .prepend('')
                .find(':first');    
    

提交回复
热议问题