我有一个图像“查看更多”,当我单击更多数据时,我想做的是在添加数据之前更改图像,我尝试了多种在Internet上找到的解决方案,但nothig似乎有效。这是我的代码
<script language="Javascript">
function openFromButton(lastLoadedIndex) {
lastLoadedIndex = (typeof(lastLoadedIndex)=='undefined') ? '' : lastLoadedIndex;
jQuery.get('liste_ti.asp?from_item='+ lastLoadedIndex +'¶m='+(new Date()).getTime(), function(data) {
//alert(data);
jQuery("#liste").append(data);
});
}
</script>
和我的形象
<div class="lazyLoading"><a href="#"> <img src="images/view_more_arrow.png" border="0" height="6" width="11"></a> <a href="javascript:openFromButton()">view more</a></div></td>
试试这个 :
给您的img这样的ID:
<div class="lazyLoading"><a href="#"> <img id="yourid" src="images/view_more_arrow.png" border="0" height="6" width="11"></a> <a href="javascript:openFromButton()">view more</a></div></td>
现在将代码更改为此:
<script language="Javascript">
function openFromButton(lastLoadedIndex) {
lastLoadedIndex = (typeof(lastLoadedIndex)=='undefined') ? '' : lastLoadedIndex;
//change it here if you want to put a loading img.
// jQuery("#yourid").attr('src','your/loading/img/url');
jQuery.get('liste_ti.asp?from_item='+ lastLoadedIndex +'¶m='+(new Date()).getTime(), function(data) {
//alert(data);
jQuery("#liste").append(data);
//change it here to be shown after the text is appended (loading finished ;) )
jQuery("#yourid").attr('src','your/img/url');
});
}
</script>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句