djairo
djairo

Reputation: 2743

Javascript undefined variable

I have a problem with a javascript error: $("#slider") is undefined

How can i solve this problem?

<script type="text/javascript">
$(document).ready(function() {
    $("#slider").easySlider({
        controlsBefore: '<p id="controls">',
        controlsAfter: '</p>',
        prevId: 'prevBtn',
        nextId: 'nextBtn'
    });
});
</script>

This is my html

<div id='slider'>
    <table>
        <tr>
            <td width='325'>hello</td>
            <td width='325'>hello</td>
    </table>
</div>

Upvotes: 1

Views: 3491

Answers (3)

x4tje
x4tje

Reputation: 1643

jQuery(document).ready(function() {
    jQuery("#slider").easySlider({
        controlsBefore: '<p id="controls">',
        controlsAfter: '</p>',
        prevId: 'prevBtn',
        nextId: 'nextBtn'
    });
});

Probebly you got more then 1 jQuery script try this script if it work you have to change the order of script use

Upvotes: 2

Juan Techera
Juan Techera

Reputation: 1202

try:

$(document).ready(function(){
    alert("jquery is working");
});

if this dont make a alert pop up your problem is in the link to jquery. I hope it helps ;)

Upvotes: 1

nickf
nickf

Reputation: 545985

I doubt there's a problem in the code you've pasted here -- even if you wrote something like this:

$('bladkhadlhadkjha').easySlider({ ... });

You wouldn't be getting the "undefined" error, since jQuery would handle that gracefully. Make sure that jQuery is being included properly, your plugin is being included properly and that the code you've pasted is exactly the code you're having the problem with.

Upvotes: 1

Related Questions