2012-12-07 32 views
0

即時通訊使用一個自定義js編碼在一個小提琴中,我想要將它整合到我的wordpress主題:我已經使用寄存器和入隊腳本如下,並且他們似乎加載正確,但是這是custom.js似乎是錯誤的。語法錯誤在JS

請有人告訴我,如果我錯過了一個標籤或一些東西,因爲我卡住了。下面是我的代碼: -

/我的功能文件/

<?php 
if (!is_admin()) add_action("wp_enqueue_scripts", "my_jquery_enqueue", 11); 
function my_jquery_enqueue() { 
wp_deregister_script('jquery'); 
wp_register_script('jquery', "http" . ($_SERVER['SERVER_PORT'] == 443 ? "s" : "") ."://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js", false, null); 
wp_enqueue_script('jquery'); 

wp_register_script('jquery-ui', get_template_directory_uri().'/js/jquery-ui.min.js', array('jquery'), true); 
wp_enqueue_script('jquery-ui'); 

wp_register_script('custom', get_template_directory_uri().'/js/custom.js', array('jquery-ui'), true); 
wp_enqueue_script('custom'); 
} 
?> 

/我的自定義JS文件 */

$(document).ready(function() { 
$("h1, h2").on('click', function (e) { 
e.preventDefault(); 
$(this).effect("bounce", { times : 2, direction : "down", distance : "3" }, 200) 
}); 

三江源 科斯蒂

+0

請發佈語法錯誤。 –

+0

你已經試過了什麼?你真的試圖解決你的問題嗎?也許你想閱讀[this](http://en.wikipedia.org/wiki/JavaScript_syntax)。 –

+2

[添加正確的縮進和間距](http://jsbeautifier.org/)將幫助您極大地識別語法錯誤。 – jbabey

回答

7

您忘了關閉您的文檔了。已準備好

$(document).ready(function() { 
    $("h1, h2").on('click', function(e) { 
     e.preventDefault(); 
     $(this).effect("bounce", { 
      times: 2, 
      direction: "down", 
      distance: "3" 
     }, 200); 
    }); 
});​ 
+1

和一個分號後 '$(this).effect(「bounce」,{ times:2 , 方向:「向下」, 距離:「3」 },200)' –

+0

Upvote。謝謝。 – Magicmarkker

+0

晶圓廠的東西,謝謝你們:)它似乎已經工作:) –