Javascript onclick span->;loading.gif未显示在ajaxStart JS中
我正在用css做一个带有跨距的表格。单击跨度时,我希望在脚本在数据库中插入一些数据时显示正在加载的gif 这是跨度:Javascript onclick span->;loading.gif未显示在ajaxStart JS中,javascript,jquery,ajax,onclick,gif,Javascript,Jquery,Ajax,Onclick,Gif,我正在用css做一个带有跨距的表格。单击跨度时,我希望在脚本在数据库中插入一些数据时显示正在加载的gif 这是跨度: <span class="label label-<?=$tag?><?=$selected?" selected":" hidden-print"?> customer-<?=$i?>" onclick="connect('customer-<?=$i?>', '<?=$customer?>', '<?=$
<span class="label label-<?=$tag?><?=$selected?" selected":" hidden-print"?> customer-<?=$i?>" onclick="connect('customer-<?=$i?>', '<?=$customer?>', '<?=$tag?>');"><?=$tag?></span><?
$('.loading.gif').show()将不会加载图像并显示它。最好的方法是使用一些html
<img class="loader" src="loader.gif"/>
html
<img src="loading.gif" id="loader" alt="loading"/>
js
#loader { display:none; }
$("#loader").show();
<html>
<head>
<title>Showing placement of these parts</title>
<style>
#loader { display:none; }
</style>
</head>
<body>
<img src="loading.gif" id="loader" alt="loading"/>
<script src="pathto/jquery.js"></script>
<script>
$("loader").show();
</script>
</body>
</html>
问题是您的代码:
$(“load.gif”).show()
-实际上不会将元素带入页面
更新为评论问题
#loader { display:none; }
$("#loader").show();
<html>
<head>
<title>Showing placement of these parts</title>
<style>
#loader { display:none; }
</style>
</head>
<body>
<img src="loading.gif" id="loader" alt="loading"/>
<script src="pathto/jquery.js"></script>
<script>
$("loader").show();
</script>
</body>
</html>
.loading.gif是html元素中的一个类,还是您认为.loading.gif.show()将显示图像本身??对于什么是“css#loader{display:none;}”?一旦您将图像添加到html中的页面,您将希望将其隐藏到视图中,直到您将其显示出来(.show()创建display:block的css,.hide()创建display:none的css)好的,我添加了ccs,但仍然不起作用。我应该把html代码放在哪里?在html标记和javascript代码之间的某个地方。嘿,对不起。我照你说的做了,效果很好!但当我单击span时,loading.gif从未停止。它在我的手机上运行得很好,问题是在pc上。我必须把它放在哪里?@Nandips,你可以把它放在HTML文件中,你想让你的加载程序显示在哪里
<html>
<head>
<title>Showing placement of these parts</title>
<style>
#loader { display:none; }
</style>
</head>
<body>
<img src="loading.gif" id="loader" alt="loading"/>
<script src="pathto/jquery.js"></script>
<script>
$("loader").show();
</script>
</body>
</html>
$(document).ajaxStart(function(){
$('loader').show();
alert('Cargando la etiqueta');
}).ajaxComplete(function(){
$('loader').hide();
alert('Etiqueta cargada');
});
});