Top Banner
JavaScript Training Goal Trainers Format Lecture Exercises Ask Questions! bitovi/js-trainin
4
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Element attributes and properties

JavaScript Training

Goal Trainers Format

• Lecture• Exercises• Ask Questions!• bitovi/js-training

Page 2: Element attributes and properties

Attributes and Properties

Page 3: Element attributes and properties

get/set Element properties

element.getAttribute( attributeName )element.setAttribute( attributeName , value )element.removeAttribute( attributeName )

element.idelement.classNameanchor.hrefinput.type

Page 4: Element attributes and properties

Exercise

Add an attr method to $ that gets/sets attributes:

$('ul li a').attr('class', 'active');

$('ul li a').attr('href') //-> '#Doberman'