0

I need to transform this :

<input type="button" value="O">

In a text. Anyone can help me?

Fuffy
  • 495
  • 1
  • 5
  • 8

4 Answers4

1
$('input')[0].outerHTML

demo

Get selected element's outer HTML

Community
  • 1
  • 1
AmmarCSE
  • 28,122
  • 5
  • 36
  • 49
0

Using the following straight DOM code works just fine:

var input = document.createElement('input');
input.type = 'button';
document.body.appendChild(input);
input.type = 'text';
input.value = 'this is text';

more infos Here

Community
  • 1
  • 1
Maraboc
  • 9,461
  • 2
  • 30
  • 45
0

If I have understood the question correctly following snippet you should do the trick:

$('input[type=button][value=0]').replaceWith(function() {
    return document.createTextNode(this.outerHTML);
});

The above snippet basically replaces the element with it's string representation.

http://jsfiddle.net/aet4u3e1/

undefined
  • 136,817
  • 15
  • 158
  • 186
0

You can use in pure HTML like this.

<pre>
    &ltinput type="button" value="O"&gt
</pre>

Using java script you can find and replace < >.

Ex: HTML.replace(/&/g, '&amp;').replace(/</g, '&lt;');
PHJCJO
  • 397
  • 2
  • 15