テキストデータをjqueryオブジェクトに変換したいのですが、「find()」メソッドや「filter()」メソッドなど、jqueryが持っているメソッドを使いたいです。
しかし、どういうわけか、変換されたjqueryオブジェクトのinnerHtmlは私が期待したものではありません..
何が起こっているのか知りたい.
http://jsfiddle.net/LxXtz/14/
<!DOCTYPE html>
<html>
<head>
<script src="lib/jquery-2.0.3.min.js"></script>
<style type="text/css">
<!--
#parts{
display: none;
}
-->
</style>
<script>
$(function () {
$('#execution').on('click', function () {
var parts = $('#parts').html(); //Parts is text data. I create the data from html just for this demo.
var partsobj = $(parts); // Convert to jQuery object.
console.log(partsobj.html()); // Why not be outputted innerHtml of #parts??
});
});
</script>
</head>
<body>
<input type="button" id="execution" value="Execute" />
<div id="parts">
<div id="div1">
<div>This is in Div1</div>
</div>
<div id="div2">This is Div2</div>
</div>
</body>
</html>