[英]jsFiddle working, website JS not working
Tried lots of different things, but can't seem to get this working in the live site. 尝试了许多不同的方法,但似乎无法在实时站点中正常工作。
<script type="text/javascript" src="/jquery.min.js"></script>
<script type="text/javascript">
$('.upme-field-value').filter(function(){
$this = $(this);
if ($this.text() === "Verified") {
$this.html('<div id="verifiedText">Verified</div><img alt="Passed" src="/wp-content/uploads/2013/11/verified1.png"/>');
$this.find('#verifiedText').hide();
}
});
</script>
here is it working in fiddle http://jsfiddle.net/4MLX3/11/ 这是在小提琴中工作吗http://jsfiddle.net/4MLX3/11/
I've disabled js minify I've uploaded the js source file to the website I've put the script first in the header I've checked for errors using Chrome Developer tools, but nothing seems to work 我已禁用js缩小功能,已将js源文件上传到网站,我已将脚本放在标题中,然后使用Chrome Developer工具检查了错误,但似乎无济于事
In jsFiddle, by default the script runs under a window.onload
handler(2nd dropdown in the left panel). 在jsFiddle中,默认情况下,脚本在window.onload
处理程序(左侧面板中的第二个下拉菜单)下运行。
Add your code in a dom ready handler 将代码添加到dom ready处理程序中
jQuery(function ($) {
$('.upme-field-value').filter(function () {
$this = $(this);
if ($this.text() === "Verified") {
$this.html('<div id="verifiedText">Verified</div><img alt="Passed" src="/wp-content/uploads/2013/11/verified1.png"/>');
$this.find('#verifiedText').hide();
}
});
})
Jquery ready handler missing in your script section. 您的脚本部分中缺少jQuery就绪处理程序。
$(function(){
$('.upme-field-value').filter(function(){
$this = $(this);
if ($this.text() === "Verified") {
$this.html('<div id="verifiedText">Verified</div><img alt="Passed" src="/wp-content/uploads/2013/11/verified1.png"/>');
$this.find('#verifiedText').hide();
}
});
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.