为什么我的html和js只适用于codepen

时间:2016-06-05 23:11:34

标签: javascript html

这是我工作的链接,它在Codepen上完美运行,但当我将它移动到我的github个人页面时,它不会起作用。当我按下搜索按钮时没有响应。 https://gist.github.com/Airhaoran/eec810eda0299297a59d83d353d732ea

2 个答案:

答案 0 :(得分:1)

尝试将代码包装在文档就绪函数中。

示例1:

$('document').ready(function(){

//Place all of your code here

})

或可选

if(document.readyState == "complete" || document.addEventListener){

 //Place all of your code here

}

这在github doc中不存在。

希望这会有所帮助..

答案 1 :(得分:0)

我认为缺少Jquery库,因为它使用的是$(“。mysearch”)。单击(codepen中的function()并将jquery库添加到笔中。

我认为你的github个人页面中缺少它。

希望这对你有帮助:))