Categories
JavaScript

Modifying tag attributes with JQuery

  • var imageFile = $(‘#banner img’).attr(‘src’); // To load a javascript variable the ‘src’ part of img tag inside #banner tag
  • var imageFile = $(‘#banner img’).attr(‘src’,’new/path/here’); // To modify the current attribute
  • $(‘body’).removeAttr(‘bgColor’); // To remove an attribute