Questions tagged [outerhtml]

80 questions
23
votes
5 answers

outerHTML of an SVG element

Why can not we get outerHTML of an svg element with element.outerHTML property? Is this way is the best http://jsfiddle.net/33g8g/ for getting svg source code?
ivkremer
  • 1,234
  • 3
  • 23
  • 42
20
votes
3 answers

When should you use outerHTML in JavaScript?

What are the differences between when you should use innerHTML and outerHTML. And how would you best implement the outerHTML to replace or add content?
symfony
  • 915
  • 2
  • 13
  • 20
18
votes
9 answers

get opening tag including attributes - outerHTML without innerHTML

I would like to retrieve a certain tag element with its attributes from the DOM. For example, from link text I want to get , optionally with a closing , either as a string or some…
Richard Kiefer
  • 1,814
  • 2
  • 23
  • 42
16
votes
4 answers

How to return outer html of DOMDocument?

I'm trying to replace video links inside a string - here's my code: $doc = new DOMDocument(); $doc->loadHTML($content); foreach ($doc->getElementsByTagName("a") as $link) { $url = $link->getAttribute("href"); if(strpos($url, ".flv")) { …
Fuxi
  • 7,611
  • 25
  • 93
  • 139
14
votes
2 answers

Why does outerHTML bring back comments?

I have a jsfiddle here - http://jsfiddle.net/stevea/QpNbu/3/ - that collects the outerHTML for all elements that have class='active'. What amazes me is that even if I comment out some of the HTML, as in: