duanjing7651
2016-06-25 08:58
采纳率: 0%
浏览 243
已采纳

如何将JS从HTML实现到WordPress?

Recently, I'm really interested in building WordPress template. I started doing it, but I am really stuck now. The thing is, i have HTML file of my frontpage (index.html), and the CSS and JS all in their folders. Now, I can't seem to find a way to make the JS work on WordPress platofrm, like its working on HTML.

I only want to make that menu work, don't mind the other bugs.

http://brainstorm.comoj.com/ -- HTML

http://bsarafimov21.byethost16.com/ -- WordPress

Here is the code i want to transfer from HTML to WordPress:

<script type="text/javascript">
    $(document).ready(function () {
        var trigger = $('.hamburger')
            , overlay = $('.overlay')
            , isClosed = false;

        trigger.click(function () {
            hamburger_cross();
        });

        function hamburger_cross() {

            if (isClosed == true) {
                overlay.hide();
                trigger.removeClass('is-open');
                trigger.addClass('is-closed');
                isClosed = false;
            } else {
                overlay.show();
                trigger.removeClass('is-closed');
                trigger.addClass('is-open');
                isClosed = true;
            }
        }

        $('[data-toggle="offcanvas"]').click(function () {
            $('#wrapper').toggleClass('toggled');
        });
    });
</script>

图片转代码服务由CSDN问答提供 功能建议

最近,我真的对构建WordPress模板感兴趣。 我开始这样做,但我现在真的被困住了。 问题是,我有我的首页的HTML文件(index.html),以及他们的文件夹中的CSS和JS。 现在,我似乎无法找到一种方法让JS在WordPress平台上工作,就像它在处理HTML一样。</ p>

我只想让菜单工作,不要介意 其他错误。</ p>

http://brainstorm.comoj.com/ - HTML </ p>

http://bsarafimov21.byethost16.com/ - WordPress </ p>

以下是我想从HTML传输到WordPress的代码:</ p>

 &lt; script type =“text /  javascript“&gt; 
 $(document).ready(function(){
 var trigger = $('。hamburger')
,overlay = $('。overlay')
,isClosed = false; 
  
 trigger.click(function(){
 hamburger_cross(); 
}); 
 
函数hamburger_cross(){
 
 if if(isClosed == true){
 overlay.hide();  
 trigger.removeClass('is-open'); 
 trigger.addClass('is-closed'); 
 isClosed = fa  lse; 
} else {
 overlay.show(); 
 trigger.removeClass('is-closed'); 
 trigger.addClass('is-open'); 
 isClosed = true; 
}  
 
 
 $('[data-toggle =“offcanvas”]')。click(function(){
 $('#wrapper')。toggleClass('toggled'); 
});  
}); 
&lt; / script&gt; 
 </ code> </ pre> 
 </ div>

5条回答 默认 最新

相关推荐 更多相似问题