Ahmad Gulzar
Ahmad Gulzar

Reputation: 363

jQuery function not found in wordpress

i have some code in simple html and it works fine but when i put in wordpress it does not work. its simple jquery slider which i am putting by hardcode in index.php

here is how i am adding script

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

here is html which i am putting in index.php file after body tag

<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>

and here is jquery where i am calling slider function

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

so when i check using firebug, it show bjqs is not a function but bjqs.js file is also loading fine. and the same code works fine in local html file

Upvotes: 1

Views: 192

Answers (3)

Ranjith
Ranjith

Reputation: 163

Try this way to work

jQuery( document ).ready(function() {

// here your code


});

Upvotes: 2

Ahmad Gulzar
Ahmad Gulzar

Reputation: 363

Problem solved. the problem was in the library code. library code was like this in the start

;(function($) {

and now i changed to

$(function($) {

and it worked fine.

Upvotes: 1

yang
yang

Reputation: 31

the way of the bjqs.file is Correct? Mybe the src is Wrong.you can log the src of bjqs.file to contain it's correct.

Upvotes: 0

Related Questions