0

I need to transform this :

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

In a text. Anyone can help me?

Fuffy
  • 625
  • 1
  • 6
  • 8

4 Answers4

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

demo

Get selected element's outer HTML

Community
  • 1
  • 1
AmmarCSE
  • 29,061
  • 5
  • 39
  • 52
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
  • 10,125
  • 3
  • 34
  • 46
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/

Ram
  • 140,563
  • 16
  • 160
  • 190
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
  • 435
  • 3
  • 17