/    Sign up×
Community /Pin to ProfileBookmark

innerHTML autowrapping text in anchor tags

[code]
respondingTo = document.createElement(“span”);
formLayoutDiv.insertBefore(respondingTo, someformelement);
respondingTo.innerHTML = “Here is some text”;
[/code]

after this code runs, i get <span><a>Here is some text</a><span>

if i change the third line to

respondingTo.innerHTML = “<span>Here is some text</span>”;

then i get <span><span><a>Here is some text</a></span></span>

so why is the text getting wrapped in an <a tag and what can i do to avoid that?

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@konithomimoAug 02.2006 — I used the code bit that you provided, and did not receive an <a> tag in my code . . . the <a> tag must be generated somewhere else.
Copy linkTweet thisAlerts:
@wilfordbrimleyauthorAug 06.2006 — okay.. yeah i'm using dojo.. i'll look into that..

thanks.
Copy linkTweet thisAlerts:
@konithomimoAug 06.2006 — No problem. Let us know if you need any help with it.
Copy linkTweet thisAlerts:
@wilfordbrimleyauthorAug 06.2006 — basically that element is inside a form that has a sibling textarea div with dojoType="Editor" and i'm wondering if that could be causing the difficulties, as i hadn't seen this problem elsewhere...its wierd that it affects a sibling node though... i
Copy linkTweet thisAlerts:
@konithomimoAug 07.2006 — WIthout seeing the code it is hard to say. It could be something as little as forgetting to close a tag.
×

Success!

Help @wilfordbrimley spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.27,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...