angularjs过滤器(number)
$('a').click()无法触发页面跳转

<img>加载图片失败,怎样替换为默认图片

妙音 posted @ 2015年1月05日 15:45 in webui with tags html , 11515 阅读
img元素加载图片失败,则变成一个小图标,让页面变得难看。此时如何替换为默认图片?

onerror属性

img元素自带onerror属性,加载失败时,触发error事件
<img src="image.gif" onerror='this.src="default.gif" />

jquery.error函数

jquery提供对应的事件处理函数
$('img').error(function(){
    $(this).attr('src',"default.gif");
})

jquery.one函数

使用上面两种方法,假如默认图片也加载失败,则变成死循环. 此时可使用one()绑定事件
$("img").one("error", function(e){
     $(this).attr("src", "default.gif");
});
 
另外error事件,不支持冒泡,jquery.delegate函数捕捉不到error事件。
 
Avatar_small
<a href='https://goo 说:
2023年6月27日 02:10

Thanks for sharing such information!

Avatar_small
<a href='https://goo 说:
2023年6月27日 21:03

Pretty good post. I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog posts.

<a href='https://goo.gl/maps/cLyjM5sSPe9XoXCs5' title='Tonbridge to City Airport'>Tonbridge to City Airport</a>

Avatar_small
<a href='https://goo 说:
2023年6月27日 21:27

Pretty good post. I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog posts.

<a href='https://goo.gl/maps/cLyjM5sSPe9XoXCs5' title='Tonbridge pick and drop'>Tonbridge pick and drop</a>

Avatar_small
<a href='https://goo 说:
2023年7月03日 22:01

Thanks for your valuable post, Really nice and very informative.

<a href='https://goo.gl/maps/5FStTPREPGyYhcicA' title='plumbers bristol'>plumbers bristol</a>

Avatar_small
<a href='https://goo 说:
2023年7月03日 22:26

Pretty good post. I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog posts.

Avatar_small
<a href='https://goo 说:
2023年7月03日 22:29

Pretty good post. I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog posts.

Avatar_small
<a href='https://goo 说:
2023年7月05日 15:16

It's really great. Thank you for providing a quality article.

Avatar_small
<a href='https://goo 说:
2023年7月05日 15:50

Thank you for this great contribution, I find it very interesting and very well thought out and put together.

Avatar_small
<a href='https://goo 说:
2023年7月05日 16:14

Thanks for sharing such information!

Avatar_small
<a href='https://goo 说:
2023年7月14日 21:33

Pretty good post. I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog posts.

Avatar_small
<a href='https://goo 说:
2023年7月15日 20:18

A very excellent blog post. I am thankful for your blog post. I have found a lot of approaches after visiting your post.

Avatar_small
honda leather motorc 说:
2023年7月26日 23:15

Hi I want to inform you that we are manufacturer of all kind of leather products.
We are manufacturing the best quality leather products. Order us for your service. We will not let you down. Thank you

Avatar_small
mi actividad 说:
2023年7月28日 22:42

Mi actividad es el portal principal donde puede ver sus actividades de Google, incluidas las búsquedas, los sitios que ha visitado y las películas que ha visto. Es importante tener en cuenta que al utilizar los sitios, aplicaciones y servicios de Google. mi actividad Se conservan en su cuenta de Google de forma indefinida. Puede ver o eliminar Mi actividad en el historial de Google dirigiéndose a ‘ Mi actividad ‘. También es posible dejar de almacenar la mayor parte de su actividad en cualquier momento.

Avatar_small
APSCERT 6th Model P 说:
2023年7月29日 19:06

BSEAP Board Students can Download Their Subject wise PDF Files it will be Beneficial for Study Material Practice and Regular Check Bit Bank and Question Bank, Important Questions, Students who are Attending AP 6th Class Annual Exam can make APSCERT 6th Model Paper 2024 use of this Information which we have Provided here.This Website Available AP Class Last year Exam Question Paper for Students can make a better Performance in Exam 2024.Good News AP Students who are Searching for the AP 6th Class Model Paper 2024 BSEAP Board has been Uploaded the All Subject Wise Download to the Students who are Going to Appear in the Board Examination this year.

Avatar_small
<a href='https://goo 说:
2023年8月17日 04:08

you have done a great job i hope you will do much batter in the future

Avatar_small
<a href='https://goo 说:
2023年8月17日 04:31

Thank you for this great contribution, I find it very interesting and very well thought out and put together.

Avatar_small
<a href='https://son 说:
2023年8月21日 20:12

Thanks for the update of the post and information data.

Avatar_small
<a href='https://son 说:
2023年8月21日 20:56

Thanks for sharing such a great information!

Avatar_small
<a href='https://www 说:
2023年9月14日 23:52

Thanks for sharing such information!

Avatar_small
gogo tours 说:
2023年9月19日 20:25

Gogo Tours remains the central focus of our travel agency's offerings, as we continue to prioritize exceptional experiences and unparalleled adventures for our valued customers. With Gogo Tours at the forefront, our dedicated team passionately crafts bespoke itineraries, ensuring each journey is imbued with the unique charm and authenticity that has become synonymous with Gogo Tours. Whether you're seeking a relaxing getaway or an adrenaline-pumping adventure, Gogo Tours is your trusted partner in making travel dreams a reality, offering a diverse array of destinations and a commitment to delivering memories that last a lifetime.

Avatar_small
<a href='www.ortho-c 说:
2023年10月15日 03:55

I have bookmarked your blog, the articles are way better than other similar blogs.. thanks for a great blog!

Avatar_small
<a href='https://cus 说:
2023年10月17日 17:17

Thanks for your valuable post, Really nice and very informative.

Avatar_small
<a href='https://cha 说:
2023年10月17日 18:10

Thank you for this great contribution, I find it very interesting and very well thought out and put together.

Avatar_small
Commercial Crime Ins 说:
2023年10月18日 23:59

Commercial crime insurance is a must-have for businesses in today's world. Your blog provides valuable insights into its importance and benefits. Thanks for shedding light on this crucial coverage!

Avatar_small
<a href='https://www 说:
2023年10月21日 23:26

I have bookmarked your blog, the articles are way better than other similar blogs.. thanks for a great blog!

Avatar_small
brown leather jacket 说:
2023年10月23日 01:10

I have bookmarked your blog, the articles are way better than other similar blogs.. thanks for a great blog!

Avatar_small
black leather jacket 说:
2023年10月23日 03:51

I have bookmarked your blog, the articles are way better than other similar blogs.. thanks for a great blog!

Avatar_small
Mens Fidget Ring Aus 说:
2023年11月02日 21:11

Elevate your style and soothe your mind with our exclusive collection of men's fidget rings. Crafted for both elegance and functionality, these rings offer a discreet way to manage stress and stay focused. Embrace the perfect fusion of fashion and mindfulness, tailored for the modern man.

Avatar_small
Pierving Jewellery 说:
2023年11月03日 00:15

Elevate your piercings with our exclusive Piercing Jewellery selection. Crafted for style and comfort, our pieces are designed to enhance your unique look. Explore our range and let your piercings make a statement of individuality and sophistication.

Avatar_small
<a href='https://cus 说:
2023年11月04日 00:35

Very good topic, similar texts are I do not know if they are as good as your work out

Avatar_small
GD Kitchen 说:
2023年11月08日 19:22

Investigating the origins of 'my keyword,' 'Gestational Diabetes Causes' is a crucial exploration of what triggers this condition. By delving into the various contributors to 'my keyword,' expectant mothers gain valuable insights into what leads to the development of gestational diabetes during pregnancy. Recognizing and addressing these 'my keyword' factors is essential for effectively managing this condition and ensuring a healthy pregnancy.

Avatar_small
<a href='https://cha 说:
2023年11月12日 21:21

I have bookmarked your blog, the articles are way better than other similar blogs.. thanks for a great blog!

Avatar_small
RTP Ligaciputra 说:
2023年11月13日 06:23

RTP Ligaciputra offers an engaging and immersive gaming experience. The platform's user-friendly interface and diverse game selection make it a go-to choice for both casual and avid gamers alike. Exciting and reliable – a winning combination!

Avatar_small
<a href='https://cus 说:
2023年11月14日 20:33

I have bookmarked your blog, the articles are way better than other similar blogs.. thanks for a great blog!

Avatar_small
<a href='www.ortho-c 说:
2023年11月14日 20:43

Thanks for the update of the post and information data.

Avatar_small
Best XL Pitbull Kenn 说:
2023年12月24日 13:45

Experience canine excellence at its finest with the 'Best American Bully Kennels.' Our commitment to superior breeding practices results in American Bullys of exceptional health, temperament, and conformation. Choose a lifelong companion from our distinguished kennels, where quality meets devotion.

Avatar_small
Lloyd C. Rice 说:
2024年1月02日 21:44

Embark on a soul-enriching odyssey with "Nurturing The Soul: A Journey," where each step is a tender exploration of self-discovery and inner growth. This transformative experience weaves a tapestry of enlightenment, inviting you to nurture the essence of your being. Elevate your journey as you traverse the sacred path towards a more profound connection with your soul.

Avatar_small
減脂 说:
2024年1月03日 20:34

Taking care of your health is like laying a strong foundation for a building. If the foundation is weak, the entire structure can crumble. Similarly, if you don’t manage your health, it can affect your overall well-being, academic performance, and even your social life.

Avatar_small
https://www.mindfulr 说:
2024年1月16日 20:55

Discover a world of mindful elegance at mindfulrings.com.au, where timeless jewelry pieces seamlessly blend sophistication and consciousness. Each meticulously crafted ring at mindfulrings.com.au reflects a commitment to sustainable practices, offering a unique fusion of style and mindfulness. Explore a curated collection that embraces eco-friendly materials and ethical craftsmanship, allowing you to adorn yourself with not just exquisite accessories but also a sense of purpose. Visit mindfulrings.com.au to redefine your jewelry experience with pieces that resonate with both your aesthetic preferences and ethical values.

Avatar_small
Pierced N Proud 说:
2024年1月16日 20:56

"Pierced N Proud" stands as a vibrant and expressive emblem for those who embrace body piercing as a form of self-expression. The phrase encapsulates a sense of confidence and individuality, symbolizing a community where individuals proudly showcase their unique piercings as a testament to their personal style and identity. It serves as a rallying cry for those who celebrate the beauty of body modification, fostering a sense of unity and empowerment among like-minded individuals who proudly wear their piercings as badges of self-confidence and distinction.

Avatar_small
First Super Car Rent 说:
2024年1月23日 00:56

Discover the epitome of extravagance with Luxury Supercars in Dubai. Our elite collection blends cutting-edge design with exhilarating performance, ensuring a driving experience beyond compare. Elevate your presence on Dubai's streets with our prestigious fleet, where each journey becomes a celebration of opulence and speed.

Avatar_small
taxiwaltononthames 说:
2024年1月31日 20:42

Experience convenience and reliability with Walton Taxis. Our prompt and professional service ensures comfortable rides for both local and long-distance travel. Trust Walton Taxis for seamless transportation, providing excellent service tailored to your needs with every journey.

Avatar_small
<a href='https://www 说:
2024年2月13日 03:14

I have bookmarked your blog, the articles are way better than other similar blogs.. thanks for a great blog!

Avatar_small
blooketjoin.me 说:
2024年3月01日 23:59

Moreover, Blooket join encourages collaboration among peers, as students can easily join together and compete or work together towards a common goal. This fosters a sense of camaraderie and teamwork within the classroom.

Avatar_small
youcine apk 说:
2024年3月02日 01:09

Moreover, Youcine fosters a sense of community among film enthusiasts through its forums and discussion boards. This interactive aspect allows users to engage in lively conversations, sharing insights and recommendations with like-minded individuals.

Avatar_small
Alzheimer prevention 说:
2024年3月21日 01:44

I have bookmarked your blog, the articles are way better than other similar blogs.. thanks for a great blog!

Avatar_small
Brooklynbeauty Loung 说:
2024年6月27日 11:53

Discover the ultimate pampering experience at the best salon in Brooklyn. Our expert stylists and top-notch services ensure you leave looking and feeling your absolute best. Book your appointment today and experience why we're the best salon Brooklyn has to offer.


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter