使用 JavaScript 将图像添加到页面,该页面也使用延迟加载类型功能
Adding images to a page with JavaScript that also uses a lazy load type feature
我正在尝试使用一些JavaScript将BBB和McAfee徽标添加到我们的结帐页面到"帐单和付款"部分。我写了一行有效的代码,但是,它只有在刷新页面时才有效。由于所有活动都发生在一个页面中,并且每次点击继续时都会重新加载页面,因此我不确定为什么我写的内容不起作用。我做错了什么?
<script type='text/javascript'>
$(document).ready(function(){
$("#payment h3").prepend('<style>#trustIcons1{position:absolute;right:0;top:-5px;}</style><div id="trustIcons1"><img src="//cdn.shopify.com/s/files/1/0567/6137/files/bbb-secure-trust.png?17807" alt="" class="fl" /><img class="mfes-trustmark mfes-trustmark-hover" border="0" src="//cdn.shopify.com/s/files/1/0567/6137/files/mcafee-secure-trust.png?17807" title="McAfee SECURE sites help keep you safe from identity theft, credit card fraud, spyware, spam, viruses and online scams" alt="McAfee SECURE sites help keep you safe from identity theft, credit card fraud, spyware, spam, viruses and online scams" oncontextmenu="alert(''Copying Prohibited by Law - McAfee Secure is a Trademark of McAfee, Inc.''); return false;"></div>');
})();
</script>
我认为您需要在 html 或样式或两者之前加上前缀(现在您预置一个字符串)
$(document).ready(function(){ $("#payment h3").prepend('<div id="trusticons">your other css</div>'); })();
$(document).ready(function(){ $("#payment h3").prepend('<style>your css</style>'); })();
$(document).ready(function(){ $("#payment h3").prepend('<style>your css</style><div id="trusticons">your other css</div>'); })();
相关文章:
- 延迟加载jquery后替换$(document).ready(function)
- 简单的身体加载功能不会触发我的功能
- 延迟加载背景图像时防止双重请求
- 延迟加载 脚本加载和/或执行
- 这个图像加载功能有什么作用
- 使jquery延迟加载插件在视口内工作
- 如何在水平滚动 Jquery 上实现延迟加载
- 如何使用angularjs延迟加载谷歌jsapi图表
- 切换页面后需要类似的加载功能
- 使用requirejs对延迟加载成员模块进行Typescript
- 淘汰具有延迟加载的多选下拉列表
- 机身加载功能和刷新按钮相同
- 用php只加载javascript;t触发加载功能
- Kendo UI树视图中的延迟加载(带缓存)
- 使用Twitter引导程序's Scrollspy到延迟加载(滚动加载)异步JavaScript
- Javascript客户端从ASP.NET MVC后端延迟加载模型
- 在featherlight.js中延迟加载iFrame
- 如何包含多个JS文件-延迟加载javascript
- 使用 JavaScript 将图像添加到页面,该页面也使用延迟加载类型功能
- 如何使用ReactJS实现延迟加载功能(append child不适用于React)