当您想对该事件做某事时。
确定何时已加载数据。
var loaded = false;function showNews() { //other js which show block jQuery("#loader").show(); if(loaded) return; //ajax which load content to block jQuery.ajax({ type: "GET", url: link, dataType: "html", success: function(data) { jQuery('#top-info-news').html(data);}, complete: function(){ jQuery('#loader').hide(); }, }); loaded = true;}或
one.在您想一次调用时使用。
<a href="javascript:;" title="Новости" onclick="showNews()" ></a>jQuery('.showNews').one('click', function() { // your pre});"Attach a handler to an event for the elements. The handler is executed atmost once per element."
参考



