Search code examples
javascriptjqueryhtmlmeta

Jquery append to <head> not working


For some reason this block of code will not work. It refuses to put in the meta tag within the head. Any ideas ?

<html>
<head>
<title>hello world</title>
</head>

<body>
HELLO WORLD!

<script src="http://code.jquery.com/jquery-latest.min.js"></script>

<script>
$(document).ready(function(){
  $("head").append("<meta blabla>");
});
</script> 

</body>
</html>

Solution

  • It is actually working. It will not show up if you view source because the source is the original HTML file. For example, if you try appending a string to the body, it will show up, however, if you view the source, there is no trace of the string in the body.

    ex

    <script>
    $(document).ready(function(){
      $("body").append("random sentence");});
    </script>