728x90

jQuery 특정 div 새로고침 | Refresh Specific div


Case 1

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
<script>
$(document).ready(function(){
    $("button").click(function(){
        $("#div1").load("demo_test.txt");
    });
});
</script>
</head>
<body>

<div id="div1">
    <h2>Let jQuery AJAX Change This Text</h2>
</div>

<button>Get External Content</button>

</body>
</html>

Case 2 
An easy, but not good way for performance.

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
<script>
$(document).ready(function(){
    $("button").click(function(){
        $("#div1").load(window.location.href+" #div1 h2");
    });
});
</script>
</head>
<body>

<div id="div1">
    <h2>Let jQuery AJAX Change This Text</h2>
</div>

<button>Get External Content</button>

</body>
</html>

Read more

댓글 없음:


+ Recent posts