写个简单的暂无图片插件,实现暂无图片的替换,大家如果有好的建议补充补充,就当练手了,极其简单,不过很实用。见笑了

代码如下:

头部是注释规范,纯属装逼

/*
* ImageToos1.0
*
* Copyright (c) 2011 yepeng
* Dual licensed under the MIT (MIT-LICENSE.txt)
* and GPL (GPL-LICENSE.txt) licenses.
*
*/
(
function($) {
jQuery.fn.extend({
noImg:
function(noImgsrc){
var img=$("img");
jQuery.each(img,
function(i,n){
if(n.src=="")
{
n.src
=noImgsrc;
}
});
}
});
})(jQuery);

 调用方法更简单,如下:

<script type="text/javascript">
$(document).ready(function() {
   jQuery("img").noImg("http://xxoo.com/noimg.gif"); 
});
</script>

记得引用jquery内裤就行了,至于为什么不用$,因为跟nvelocity模板冲突,喜欢简写的话高抬贵手自己替换一下

相关文章:

  • 2021-06-10
  • 2021-09-01
  • 2021-11-13
  • 2021-12-07
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-13
猜你喜欢
  • 2021-11-14
  • 2022-12-23
  • 2021-10-31
  • 2021-05-26
  • 2021-10-02
  • 2021-12-18
  • 2021-04-16
相关资源
相似解决方案