.prepend is not a function

前端 未结 2 983
庸人自扰
庸人自扰 2021-01-24 02:31

Please consider the following sample code:



    
        

        
2条回答
  •  暖寄归人
    2021-01-24 03:07

    The error appears because createElement() returns a DOMElement which does not have an append() method; that's only available on jQuery objects. You need to either wrap the DOMElement to a jQuery object or, better yet, create the element in jQuery:

    $("#btn1").click(function(){
         var btn = $('

提交回复
热议问题