jQuery 의 load()함수 가 궁금합니다 채택완료
현제 아래와 같은 제이쿼리 로드함수를 사용하고있습니다.
아래 소스대로 하면 잘불러옵니다.
<head>
<script src="https://code.jquery.com/jquery-1.9.1.min.js"></script>
<script type="text/javascript">
$( document ).ready(function() {
$("#my-iframe").load("a.html");
});
</script>
</head>
<body>
<div id="my-iframe" class="iframe">
</div>
</body>
그런데 제가 궁금한건 위소스를 보면
a.html 을 불러오라는 뜻인데
혹시 a.html 의
<div id="cake">
</div>
위 단락부분만을 불러오게도 할수있나요?
만약 가능하면 어떻게 하면 될까요?
답변 2개
직접 만들어 보았습니다.
아래의 소스를 사용해보세요. 작동할겁니다.
<script src="https://code.jquery.com/jquery-1.9.1.min.js" target="_blank">https://code.jquery.com/jquery-1.9.1.min.js"></script>
<script type="text/javascript">
$( document ).ready(function() {
$.get("a.html", {}, function(res){
$("body").append("<div id='tmpbox' style='display:none;'>"+res+"</div>");
var string = $("#cake").html();
$("#my-iframe").html(string);
$("#tmpbox").remove();
});
});
</script>
</head>
<body>
<div id="my-iframe" class="iframe"></div>
</body>
답변에 대한 댓글 1개
댓글을 작성하려면 로그인이 필요합니다.
답변을 작성하려면 로그인이 필요합니다.
로그인
$.get("a.html", {}, function(res){
이부분의 a.html 을 ../a.html 로 해도 되는건가요?