I need to have a function that puts the code inside it in an HTML "a" element. I have tried many different variations of the code posted below and none of them have worked.
var doc = document.body;
function h1(text) {
var h1 = document.createElement("h1");
var t = document.createTextNode(text);
h1.appendChild(t);
doc.appendChild(h1);
}
function a(a, b) {
var doc1 = document.createElement("a");
doc.a;
var s;
s = document.createElement('script');
s.innerHTML = b;
doc.appendChild(doc1);
doc = doc1;
doc1.appendChild(s);
doc = document.body;
}
a("href=www.google.com", "h1(\"hello\");");
Aucun commentaire:
Enregistrer un commentaire