Add css class to a javascript event -
how can add class following element?
window.location = 'page.html';
for example, i'd result:
<a href="page.html" class="nameclass">link</a>
but javascript page loads automatically after function, not link text click on.
create link element:
var = document.createelement('a'); // <a></a>
add href:
a.href = 'page.html'; // <a href="page.html"></a>
add class:
a.classname = 'nameclass'; // <a href="page.html" class="nameclass"></a>
add text:
a.innerhtml = 'link'; // <a href="page.html" class="nameclass">link</a>
append body element:
document.body.appendchild(a); // in page!
Comments
Post a Comment