title: dynamically create element using jquery
body: <p>I am trying to create element using jquery. When i click on a link, i want to create an element "p", give it some text, and then put it in one of my divs. Also, i want to check which link is clicked on, so i can put the created "p" in the right div. Any solutions on where i am doing it wrong?</p>
  
  <p>Javascript/Jquery</p>
  
  <pre><code>$(document).ready(function () {
  
  function createElement() {
    var a = $("#menu").find('a').each(function(){
      if(a == "l1"){
      var text = $(document.createElement('p');
      $('p').text("Hej");
      $("#contentl1").append("text");
      }
    });
  }
  
  $("#menu").find('a').each(function () {
      $(this).click(function () {
          createElement();
      });
  });
  
  createElement();
  
  });
  </code></pre>
  
  <p>HTML</p>
  
  <pre><code>      &lt;html&gt;
  
  &lt;head&gt;
  &lt;title&gt;Inl1-1&lt;/title&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8"&gt;
  &lt;link rel="stylesheet" type="text/css" href="style-1.css"&gt;
  &lt;script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript" src="Uppg1.js"&gt;&lt;/script&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
  
  &lt;ul class="meny" id="menu"&gt;
  &lt;li&gt;&lt;a href="#" id="l1"&gt;Utvärdering/Feedback&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href="#" id="l2"&gt;Kontakt&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href="#" id="l3"&gt;Öppettider&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href="#" id="l4"&gt;Om Asperöd&lt;/a&gt;&lt;/li&gt;
  &lt;/ul&gt;
  
  &lt;div id="contentl1"&gt;
  
  &lt;/div&gt;
  
  &lt;div id="contentl2"&gt;
  
  &lt;/div&gt;
  
  &lt;div id="contentl3"&gt;
  
  &lt;/div&gt;
  
  &lt;div id="contentl4"&gt;
  
  &lt;/div&gt;
  
  &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>