An Easier Way?
jQuery is a DOM manipulation library
It comes with a bunch of useful methods to things like:
Either way, it's worth knowing.
<script type="text/javascript" src="https://code.jquery.com/jquery-2.1.4.js"></script>
<script type="text/javascript" src="jquery.js"></script>
Download jQuery and link to it locally:
OR
Link to a CDN(a hosted copy)
Here's a 30 second preview of what jQuery looks like:
//when a user clicks the button with id 'trigger'
$('#trigger').click(function(){
//change the body's background to yellow
$('body').css("background", "yellow");
///fade out all img's over 3 seconds
$('img').fadeOut(3000, function() {
//remove imgs from page when fadeOut is done
$(this).remove();
});
});