How to convert an HTML to a jQuery object?
var objeto = '<div id="minhaDiv"><span id="meuSpan">Span</span></div>';
How to convert an HTML to a jQuery object?
var objeto = '<div id="minhaDiv"><span id="meuSpan">Span</span></div>';
Very simple, just instantiate jQuery by passing HTML as a parameter.
var teste = $('<div id="minhaDiv"><span id="meuSpan">Span</span></div>').find("span").text();
$("#result").html(teste);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script><divid="result"></div>
You can use innerHTML
native.
Example
var objeto = '<div id="minhaDiv"><span id="meuSpan">Span</span></div>';
document.getElementById("ID_DIV").innerHTML = objeto ;
Or you can use JQuery
:
var objeto = '<div id="minhaDiv"><span id="meuSpan">Span</span></div>';
$("#ID_DIV").html(objeto );