html():HTMLの値を取得する
2016/04/19
HTMLの値を取得するの書式
$("要素名").html();
HTMLの値を取得する場合は、
$("要素名").html();を記述します。
htmlメソッドを使用します。
具体例(HTMLの値を取得するのサンプルコード)
サンプルでは以下の事をしてます。
1.htmlメソッドを使って、divタグidがdivHtmlのhtmlの取得。
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="utf-8">
<title></title>
<style type="text/css">
<!--
body {background-color: #ffffff;}
-->
.classAttention { color: #ff0000; font-weight: bold; }
</style>
<script src="../../js/jquery-1.12.2.min.js"></script>
<script>
$(function(){
var result;
result = $("div#divHtml").html();
$("#resultDiv").text('divタグidがdivHtmlのhtmlは' + result);
});
</script>
</head>
<body>
<div id = "divHtml">
<ul>
<li>1</li>
<li>2</li>
<li>3</li>
</ul>
</div>
<div id = "resultDiv"></div>
</body>
</html>
