How to put a display a default image if no src specified?
I have HTML from a database that sometimes give no src values like this:
<img class="some-image" src=""开发者_StackOverflow>
How do I supply it with an image if there is no src value like above?
You can test the src attribute to see if it's empty:
$('img[src=""]').attr("src", "default.jpg");
$('img[src=""]').attr('src', 'urltoimage');
You can define it on the css class as background for the tag and overwrite it with the src tag where available. Are you meaning this?
精彩评论