未注释img´除非调整浏览器大小、缩放或打开开发工具,否则不会显示
Uncommented img´s not showing unless resizing browser, zooming or opening dev tools
我使用了一种取消注释的方法来延迟加载我的图像。我有理由这样做,它运行得很好,除了我需要调整浏览器大小、缩放或打开开发工具才能让它们显示出来。我认为当我这样做的时候,元素会更新。有没有任何方法可以通过javascript模拟这3个操作中的任何一个,或者有任何方法可以刷新我的.conta容器div中的图像?
下面是Jquery im使用的:
(function($) {
$.fn.uncomment = function(recurse) {
$(this).contents().each(function() {
if ( recurse && this.hasChildNodes() ) {
$(this).uncomment(recurse);
} else if ( this.nodeType == 8 ) {
var e = $('<span>' + this.nodeValue + '</span>');
$(this).replaceWith(e.contents());
}
});
};
})(jQuery);
点击后,图像应该开始出现,但只有在稍微调整窗口大小时:
$('button').click(function(e) {
e.preventDefault();
$('#music').uncomment(/* recurse */ true );
});
尝试将translate
添加到内容:
(function($) {
$.fn.uncomment = function(recurse) {
$(this).contents().each(function() {
if ( recurse && this.hasChildNodes() ) {
$(this).uncomment(recurse);
} else if ( this.nodeType == 8 ) {
var e = $('<span>' + this.nodeValue + '</span>');
$(this).replaceWith(e.contents());
$(this).css({'translateX' : 0});
}
});
};
})(jQuery);
或在窗口上触发resize
事件
(function($) {
$.fn.uncomment = function(recurse) {
$(this).contents().each(function() {
if ( recurse && this.hasChildNodes() ) {
$(this).uncomment(recurse);
} else if ( this.nodeType == 8 ) {
var e = $('<span>' + this.nodeValue + '</span>');
$(this).replaceWith(e.contents());
}
$(window).trigger('resize');
});
};
})(jQuery);
相关文章:
- Chrome开发工具(如何知道我在调用哪个javascript对象)
- 更改高贴图的缩放级别
- 在不阻止默认行为的情况下检测IE10中的缩放
- 单击超链接时,如何使用Google Maps API v3缩放地图
- 缩放Raphael/SVG容器以适应所有内容
- 传单缩放控制位置错误
- 在不移动内部文本的情况下缩放元素的效果
- 调整缩放窗口高度提升缩放
- 计算CSS3缩放框在另一个框中的最高位置
- D3.JS向rect添加缩放和列表项
- 当我在节点上拖动鼠标时,我如何防止使用d3.ehavior.zoom().on(“缩放”,重绘)
- 将直流图表库中的折线图缩放限制为小时
- 为什么缩放按钮不会显示在照片擦除中
- 动态设置谷歌地图缩放
- Chrome开发工具中使用了哪些框架和库
- 如何缩放像图像一样的元素
- 使用KineticJS变换(移动/缩放/旋转)形状
- 未注释img´除非调整浏览器大小、缩放或打开开发工具,否则不会显示
- 缩放和缩放工具选项
- D3:如何处理单个图表中的缩放和工具提示