Q:

Create a division using jQuery with style tag using jquery

0

Create a division using jQuery with style tag 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>Create a div using jQuery with style tag.</title>
  </head>
  <body>
  <p>This domain is established to be used for illustrative examples in documents. You may use this domain in examples without prior coordination or asking for permission.</p> 
  <input type="button" value="Click to add new division" onclick="new_div()" />
</body>
  </html>

JavaScript Code :

function new_div() {
$(document).ready(function() {
  var test = {
    id: "div",
    class: "divclass",
    css: {
      "color": "Green"
    }
  };
  var $div = $("<div>", test);
  $div.html("New Division");
  $("body").append($div);
});
}

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