Quotes help make search much faster. Example: "Practice Makes Perfect"

Thursday, November 8, 2012

Codecademy: Sample Solution to "Created Elements are Real" for the jQuery track



//Sample Solution to script.js
$(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.attr('class','important');

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

});
});

No comments:

Post a Comment


This is an example of scrolling text using Javascript.

Popular Posts