Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javascript string representation of HTML element

Tags:

javascript

I have a <span> element as follows:

<span style="position: absolute; top: -42px; right: 2px; z-index: 100;" data-ng-click="DeleteImageProperties(img.vehicleId, img.vehiclePhotoId, img.fileName)">×</span>

And I am reading this <span> like this:

var outerHTML = itemelement[0];

it returns the above output, but I want to convert it to string. If I use:

outerHTML.toString()

it just returns:

[object HTMLSpanElement]

How could I get a pure string representation of my <span>?

like image 601
Gayan Kalanamith Avatar asked Oct 19 '22 12:10

Gayan Kalanamith


1 Answers

It looks like you really want outerHTML.outerHTML, as it's clearly not the outer HTML, but a DOM node in a variable with a strange name

like image 71
adeneo Avatar answered Oct 27 '22 00:10

adeneo