3.3 jQuery, DOM manipulation

  • jQuery allows JavaScript developers to perform DOM manipulation, that is, interacting with HMTL elements, in a more user-friendly manner than with pure JavaScript.
// select the button
var btn = document.getElementById('mybutton');
// event
btn.addEventListener('click', function() {
  alert('You clicked me!'); // action
});
$('#mybutton').on('click', function() {
  alert('You clicked me!');
});