不包含时间脚本不工作

not contains time script not working

本文关键字:工作 脚本 时间 包含      更新时间:2023-09-26

这是我的代码:

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js">
<span class='whocares'><div class='box'><span style='font-size:20px;color: #0BB;'>12/26/2012 is the best</span></div><br></span><span class='whocares'><div class='box'><span style='font-size:20px;color: #0BB;'>12-26-2012</span></div><br></span><span class='whocares'><div class='box'><span style='font-size:20px;color: #0BB;'>messa coockcook</span></div><br></span><script>
$(document).ready(function() {
var currentTime = new Date()
var month = currentTime.getMonth() + 1
var day = currentTime.getDate()
var year = currentTime.getFullYear()
$(".whocares:not(:contains('" + month + "/" + day + "/"+ year+"'))").remove();
});
</script>

它可以在JSFiddle上工作,但不能在我的服务器上。在我的服务器上,当我运行它时,什么也没有出现。为什么会这样呢?我做错了什么?

提前感谢!

首先,查看您的源代码:

<b>Warning</b>:  file_get_contents(http://www.dumbsearch.com/reminded.txt) [<a href='function.file-get-contents'>function.file-get-contents</a>]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found
 in <b>/home/content/76/7290476/html/remindersimportant.php</b> on line <b>4</b><br />

其次,你需要考虑不同时区的人。例如,我在IST时区,所以现在已经是2012年12月27日了。

除此之外,你的HTML格式不合理。

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js">

这里需要一个闭合的</script>。这就是为什么你不能在服务器上看到你的错误的原因之一。

它总是有助于保持良好的缩进代码。很容易在关键的地方发现这些错误。

你的jQuery脚本标签没有正确关闭

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<span class='whocares'><div class='box'><span style='font-size:20px;color: #0BB;'>12/26/2012 is the best</span></div><br></span><span class='whocares'><div class='box'><span style='font-size:20px;color: #0BB;'>12-26-2012</span></div><br></span><span class='whocares'><div class='box'><span style='font-size:20px;color: #0BB;'>messa coockcook</span></div><br></span>
<script>
$(document).ready(function() {
var currentTime = new Date()
var month = currentTime.getMonth() + 1
var day = currentTime.getDate()
var year = currentTime.getFullYear()
$(".whocares:not(:contains('" + month + "/" + day + "/"+ year+"'))").remove();
});
</script>