jQuery .append doesn't work

后端 未结 2 1691
北海茫月
北海茫月 2021-01-16 02:06

I want to insert something into my form, which is somewhere hard coded into plugin and I didn\'t want to mess with the plugin files, so I\'ve found .append

相关标签:
2条回答
  • 2021-01-16 02:34

    You need the document ready handler -

    <script>
    jQuery(function() { // the document ready handler shorthand
        jQuery('#edit-profile').append('<p>smth</p>');
    });
    </script>
    
    0 讨论(0)
  • 2021-01-16 02:48

    Wrap it in dom ready.Because #edit-profile should be there at the time of executing the script,

    jQuery(document).ready(function(){
      jQuery('#edit-profile').append('<p>smth</p>');
    });
    
    0 讨论(0)
提交回复
热议问题