2016-05-17 86 views
-2

我嘗試把這樣的代碼:http://codepen.io/lormski/pen/meXadK/在WordPress中放置一個自定義js代碼?

$(function() { 
    $("#tabs").tabs({ 
    show: { 
    effect: "blind", 
    direction: "right", 
    duration: 300 
    } 
}); 
    $("#accordion").accordion(); 

    var btn = $('#accordion li a'); 
    var wrapper = $('#accordion li'); 

    $(btn).on('click', function() { 
    $(btn).removeClass('active'); 
    $(btn).parent().find('.addon').removeClass('fadein'); 

    $(this).addClass('active'); 
    $(this).parent().find('.addon').addClass('fadein'); 
    }); 
}); 

在我的wordpress網站(主題阿瓦達索)

如果有人知道如何做到這一點;)

+0

你需要知道如何自定義的js文件鏈接到你的主題? – Ajith

+0

是的請!謝謝 – sahnas

回答

-1

$選擇在WordPress會失敗,你需要開始你的代碼:

<script> 
jQuery(document).ready(function($){ 
    //your code here using $ 
}); 
</script> 

在AVADA,你可以去選項 - >高級 - > Co de Fields(Tracking等)並在其中添加代碼。

編輯:

請注意,codepen包含jQuery UI!

如果未包含jQuery UI,則還需要在主題中包含jQuery UI。這種加入AVADAs孩子的functions.php

function my_scripts() { 
     wp_enqueue_script('jquery-ui-core'); 
} 
add_action('wp_enqueue_scripts', 'my_scripts'); 

希望幫助

+0

我在控制檯有這個錯誤: (index):218未捕獲TypeError:jQuery(...)。tabs不是一個函數(匿名函數)@(index):218i @ jquery.js?ver = 1.12.3:2j.fireWith @jquery.js?ver = 1.12.3:2n.extend.ready @ jquery.js?ver = 1.12.3:2K @ jquery.js?ver = 1.12.3:2 – sahnas

+0

I updated包括jquery ui。讓我知道這是否有效。 –

相關問題