views:

959

answers:

3

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>
+1  A: 

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.

nickf
But i have included jQuery in my script can it be something else ?
djairo
I've copied the essential parts of your code into JSBin here: http://jsbin.com/aribe/edit and it seems to be working fine. I'd suggest re-examining your code to make sure there's no silly mistakes anywhere. Also, try using "jQuery()" instead of "$()"
nickf
A: 

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

SinneR
+2  A: 
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

x4tje