se8820726
یک شنبه 05 آذر 1391, 21:14 عصر
سلام دوستان
چرا این اسکریپت کار نمیکنه؟
<!doctype html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
<script>
$(function(){
var img = new Array();
$("#pics img").each(function(i,imag){
img[i] = new image();
img[i].onload = function() {
$(imag).attr('src',img[i].src);
}
img[i].src = "img/a.png";
});
});
</script>
</head>
<body>
<div id="pics">
<img class='pic' src='img/preload.gif' alt=''>
<img class='pic' src='img/preload.gif' alt=''>
<img class='pic' src='img/preload.gif' alt=''>
<img class='pic' src='img/preload.gif' alt=''>
</div>
</body>
</html>
چرا این اسکریپت کار نمیکنه؟
<!doctype html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
<script>
$(function(){
var img = new Array();
$("#pics img").each(function(i,imag){
img[i] = new image();
img[i].onload = function() {
$(imag).attr('src',img[i].src);
}
img[i].src = "img/a.png";
});
});
</script>
</head>
<body>
<div id="pics">
<img class='pic' src='img/preload.gif' alt=''>
<img class='pic' src='img/preload.gif' alt=''>
<img class='pic' src='img/preload.gif' alt=''>
<img class='pic' src='img/preload.gif' alt=''>
</div>
</body>
</html>