<html>
<head>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("div").ajaxStart(function(){
$(this).html("<img src='http://www.w3schools.com/jquery/demo_wait.gif' />");
});
$("button").click(function(){
$("div").load("http://www.google.com/images/logos/ps_logo2.png/");
});
});
</script>
</head>
<body>
<div><h2>Let AJAX change this text</h2></div>
<button>Change Content</button>
</body>
</html>
答案 0 :(得分:3)
没有。只需创建一个img
元素,设置src
,然后将其放在您希望的位置。
$("div").empty().append($("<img/>", {src: "http://www.google.com/intl/en_ALL/images/srpr/logo1w.png"}));
答案 1 :(得分:1)
可能是
<html>
<head>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("div").ajaxStart(function(){
$(this).html("<img src='http://www.w3schools.com/jquery/demo_wait.gif' />");
});
$("button").click(function(){
$("div").html("<img src='http://www.w3schools.com/jquery/demo_wait.gif' />");
});
});
</script>
</head>
<body>
<div><h2>Let AJAX change this text</h2></div>
<button>Change Content</button>
</body>
</html>