簡體   English   中英

在wordpress中找不到jQuery函數

[英]jQuery function not found in wordpress

我有一些簡單的HTML代碼,它工作正常但是當我放入wordpress它不起作用。 它的簡單jquery滑塊,我在index.php中通過硬編碼放置

這是我如何添加腳本

<script src="<?php echo PARENT_URL; ?>/js/bjqs.js" type="text/javascript"></script>

這里是我在body標簽后放入index.php文件的html

<div class="bjqs-slider">
    <ul class="bjqs">
        <li><img src="urlofimage.jpg" alt=""></li> 
        <li><img src="urlofimage.jpg" alt=""></li> 
        <li><img src="urlofimage.jpg" alt=""></li> 
    </ul>
</div>

這里是jquery我在調用滑塊功能

$(".bjqs-slider").bjqs({
    animtype      : 'slide',
    height        : 250,
    width         : 300,
    responsive    : true,
    randomstart   : true
});

所以當我使用firebug檢查時,它顯示bjqs is not a function但bjqs.js文件也正常加載。 並且相同的代碼在本地html文件中正常工作

試試這種方式

jQuery(document).ready(function(){

// here your code


});

問題解決了。 問題出在庫代碼中。 庫代碼在開始時是這樣的

;(function($) {

現在我換了

$(function($) {

它工作得很好。

bjqs.file的方式是正確的嗎? Mybe src是錯的。你可以記錄bjqs.file的src以包含它是正確的。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM