Creating a new element and inserting before an existing causes line breaks
Jeremy L <[email protected]>
| Newsgroups | gmane.comp.mozilla.devel.dom |
|---|---|
| Organization | http://groups.google.com |
| Message-ID | <11975eb1-646d-4c5f-83dc-14d830eda42c@z38g2000hsc.googlegroups.com> |
Hi there...
I use evaluate() to parse through all <a> objects on a page, with the
goal to insert an icon before the link.
I then iterate through all the elements, and get each element using
snapshotItem(elemnum)
I then do the following:
var cisco_newcode = document.createElement("span"); // Make new code
snippit
cisco_element.parentNode.insertBefore(cisco_newcode,
cisco_element); // Switch them
var cisco_icon = document.createElement("div");
newstyle="padding-top: 0px; padding-bottom: 13px; padding-left: 8px;
padding-right: 7px; background: url('available.gif') center no-
repeat";
cisco_icon.setAttribute("style",newstyle);
var cisco_href = document.createElement("a");
cisco_href.setAttribute("href", "#");
cisco_href.addEventListener("click", MoreInfoOnLink, true);
cisco_href.appendChild(cisco_icon);
cisco_newcode.appendChild(cisco_href);
This inserts the div element with the image, but breaks the line
before and after my element - which is not the desired effect
What am I doing wrong here? It seems that just doing the insertBefore
breaks the line
J