I have this code that creates links.
/* Create a link to activate the tab */
DOM_a = document.createElement("a");
DOM_a.appendChild(document.createTextNode(t.headingText));
DOM_a.href = "javascript:void(null);";
DOM_a.title = t.headingText;
DOM_a.onclick = this.navClick;
I need to add an image to the link, but when I try to add the image code:
<img src="typo3conf/ext/ori_proyectos/res/images/interes.png">
I get:
Link<img src="typo3conf/ext/ori_proyectos/res/images/interes.png">
And not:
Link[*_*]
Where [*_*]
is the image.
The source code display this:
<img src="typo3conf/ext/ori_proyectos/res/images/interes.png">
I don't know how to write it.
Thanks.
The appendChild() method of the Node interface adds a node to the end of the list of children of a specified parent node. If the given child is a reference to an existing node in the document, appendChild() moves it from its current position to the new position.
Difference between appendChild() and append()append() also allows you to append DOMString objects, and it has no return value. Further, parentNode. appendchild() allows you to append only one node, while parentNode. append() supports multiple arguments - so you can append several nodes and strings.
You should create the image using own DOM methods too:
Something like this:
var DOM_img = document.createElement("img");
DOM_img.src = "typo3conf/ext/ori_proyectos/res/images/interes.png";
DOM_a.appendChild(DOM_img);
A working example here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With