pav
9/16/2013 - 7:14 PM

creating_new_elements_2

<html>

<head>

<title>Exercise 2.3</title>

<link rel="stylesheet" href="style.css" type="text/css"/>
<script src='script.js'></script>

</head>

<body>

<button id="changeButton">Click to run your code!</button>

<div id='content'>
<em>Not much here yet...</em>
</div>

</body>

</html>
$(document).ready(function() {
$('#changeButton').click(function() {
    
//create a new link, using either syntax
$myNewLink =$('<a />')

//add a 'href' attribute of '/links' using .attr()
$myNewLink.attr('href','/links');

//set the html of the link to 'click here!'
$myNewLink.html('click here!');

//set the class of the link to 'important'
$myNewLink.addClass('important');

//code to add the link to the page... you'll 
//learn to do this very soon!
$('body').append($myNewLink);

});
});