Q:

Add a list elements within an unordered list element using jQuery

0

Add a list elements within an unordered list element using jQuery.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

HTML Code :

<!DOCTYPE html>
<html>
<head>
<script src="https://code.jquery.com/jquery-git.js"></script>
 <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>Add li in an existing ul.</title>
  </head>
  <body>
  <div id="header">
  <ul>
  <li><a href="https://www.w3resource.com/python/python-tutorial.php">Python</a></li>
  <li><a href="https://www.w3resource.com/php/php-home.php">PHP</a></li>
  </ul>
  </div>
  <input type="button" value="Click to add new li element" onclick="new_element()" />
  </body>
  </html>

JavaScript Code :

function new_element(){
$("#header ul").append('<li>Java</li>');
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now