P5music
P5music

Reputation: 3337

Javascript: explicitly closing tags like <a/> with DOM manipulation

My Android app makes use of a WebView control where an HTML page is loaded. I am experiencing wrong behaviour of certain functions like range.getClientRects() when an user selects a range surrounding an empty anchor element like:

<a id='id' class='class'  />

and I suspect it can happen with other tags too.

I was said some browsers computes the a element to reach to the end of parent element, like a p for example, when range.getClientRects() is called. It's a wrong behaviour in my app so I would like to avoid it by closing empty tags (anchors and also other types) if that doesn't break the rendered layout (it should remain exactly the same) with Javascript DOM manipulation after HTML is loaded.

<a id='id' class='class' ></a>

Is it possible?

Upvotes: 0

Views: 63

Answers (0)

Related Questions