0

I need to transform this :

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

In a text. Anyone can help me?

Fuffy
  • 735
  • 1
  • 6
  • 8

4 Answers4

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

demo

Get selected element's outer HTML

Community
  • 1
  • 1
AmmarCSE
  • 30,079
  • 5
  • 45
  • 53
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,550
  • 3
  • 37
  • 48
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
  • 143,282
  • 16
  • 168
  • 197
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;');
PHCJS
  • 445
  • 4
  • 19