HTML - Manipulation

> (World Wide) Web - (W3|WWW) > HyperText markup Language (HTML)

1 - Manipulation

The DOM tree can be manipulated with scripts. Each element in the DOM tree is represented by an object, and these objects have APIs so that they can be manipulated.

For instance, a link (e.g. the a element in the tree above) can have its “href” attribute changed in several ways:

var a = document.links[0]; // obtain the first link in the document
a.href = 'sample.html'; // change the destination URL of the link
a.protocol = 'https'; // change just the scheme part of the URL
a.setAttribute('href', 'http://example.com/'); // change the content attribute directly
web/html/manipulation.txt · Last modified: 2019/02/09 11:29 by gerardnico