2013년 8월 10일 토요일

[HTML5, WEB표준, 웹퍼블리싱, 퍼블리셔,퍼블리서 ]jquery 강좌 문서 객체의 내부에 내용물을 추가하고 싶을 때 $(selector).html, $(selector).text

문서 객체의 내부에 내용물을 추가하고 싶을 때
 
구로디지털 오엔제이프로그래밍실무교육센터

$(selector).html(value);      $(selector).text(value);
$(selector).html(function(index, html){ });
$(selector).text(function(index, text){ });

<html><head><meta charset="utf-8"/>
<script src="/ajaxjquery/jquery-1.10.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("div").html(function (index) {
//html출력이므로 <h3>태그는 안보임
return "<h3>hello~ onjprogramming" + index + "</h3>";
});
alert(1);
$(document).ready(function() {
$("div").text("<h2>text output</h2>");//text형태로 <h2>도 출력됨
});
});
</script><body>   
<div></div>
<div></div>
</body></html>
 
 
 



댓글 없음:

댓글 쓰기