对于想了解使用默认图片代替损坏的图片网址-Js/Jquery的读者,本文将提供新的信息,我们将详细介绍javascript中制作图片代替按钮的提交效果,并且为您提供关于3Z版基于jquery的图片复选
对于想了解使用默认图片代替损坏的图片网址 - Js/Jquery的读者,本文将提供新的信息,我们将详细介绍javascript中制作图片代替按钮的提交效果,并且为您提供关于3Z版基于jquery的图片复选框(asp.net+jquery)_jquery、Flutter-显示本地json文件中的图片网址、HTML 中图片错误,使用默认的图片、jcarousellite.js 基于Jquery的图片无缝滚动插件_jquery的有价值信息。
本文目录一览:- 使用默认图片代替损坏的图片网址 - Js/Jquery(javascript中制作图片代替按钮的提交效果)
- 3Z版基于jquery的图片复选框(asp.net+jquery)_jquery
- Flutter-显示本地json文件中的图片网址
- HTML 中图片错误,使用默认的图片
- jcarousellite.js 基于Jquery的图片无缝滚动插件_jquery
使用默认图片代替损坏的图片网址 - Js/Jquery(javascript中制作图片代替按钮的提交效果)
如何解决使用默认图片代替损坏的图片网址 - Js/Jquery?
要求: 我需要用我提供的默认链接替换损坏的图片 url 链接。
$(body).find(''.timeline_profile_image'').css({ "background-image": "url(''" + doesImageExists(ajax_based_profile_image) + "'')" });
在我的 doesImageExists()
中,我检查图像 url 是否有图像,然后基于该 true|false,我想返回 URL 以添加到上述表达式中。
这是我的功能:
async function doesImageExists(image_url) {
let updated_image_url = image_url;
await $.ajax({
url: image_url,type: ''get'',async: true,error: function(response) {
this.updated_image_url = no_image_path;
}
});
return updated_image_url
}
也尝试过:
function doesImageExists(image_url) {
let returnUrl;
$.get(image_url)
.done(function() {
// Do something Now you kNow the image exists.
console.log(''success block'')
returnUrl = image_url;
return returnUrl;
}).fail(function() {
// Image doesn''t exist - do something else.
console.log(''fail block'')
returnUrl = no_image_path;
return returnUrl;
}).then(function(result) {
console.log(''then block'')
returnUrl = result;
console.log(result);
return report_url;
});
console.log(returnUrl);
return returnUrl;
}
问题 只要我在该函数内工作,上述两个函数都会显示正确的输出,但我需要返回值,以便其他函数稍后可以使用它。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)
3Z版基于jquery的图片复选框(asp.net+jquery)_jquery
先上效果图:
html:
JS:
(function($){
$.fn.imagecheckbox = function(options) {
var defaults = {
checked: "images/radio.gif",
unchecked: "no_images/radio.gif",
css: "on",
hide_radios_checkboxes: false
};
var opt = $.extend(defaults, options);
this.each(function(){
var obj = $(this);
var type = obj.attr(''type'');
var id = obj.attr(''id'');
if(!opt.hide_radios_checkboxes){
obj.css(''display'',''none'');
}
if(obj.attr(''checked'')){
$("label[for=''" + id + "'']").attr(''class'',opt.css);
}else{
$("label[for=''" + id + "'']").attr(''class'',''out'');
}
$("label[for=''" + id + "'']").click(function(){
$("#" + id).trigger("click");
if($(this).attr(''class'') == opt.css){
$(this).attr(''class'', ''out'');
}else {
$(this).attr(''class'', opt.css);
}
});
});
}
})(jQuery);