using the Firebug console I'm trying to test whether this code is working:
$(window).bind("load", function() {
    $('#tab1link').click(function() {
        $('#tab2').hide();
        $('#tab2').removeClass('selected');
        $('#tab1').show();
        $('#tab1').addClass('selected');
    });
    $('#tab2link').click(function() {
        $('#tab1').hide();
        $('#tab1').removeClass('selected');
        $('#tab2').show();
        $('#tab2').addClass('selected');
    });
});
but this:
console.log($('#tab2').hasClass('selected'))
returns the error:
 Ty开发者_StackOverflow中文版peError: $("#tab2").hasClass is not a function { message="$("#tab2").hasClass is not a function",  more...}
Does anyone know why the above console command is incorrect? (Not a jQuery expert...)
Based on the link below, I think it should work... http://api.jquery.com/hasClass/
Thanks!
Try refreshing the console/page because sometimes it doesn't properly assign $ to jQuery, assuming you're using Firebug ( it keeps the native $ function which ISNT jquery ).
You can confirm this with:
alert( $ == jQuery )
If this isn't it, then make sure you aren't using multiple libraries that use $.
Unrelated: You can also do $(function(){ /* code */ }); instead of binding on window load.
Try this instead:
console.log(jQuery('#tab2').hasClass('selected'))
It looks suspiciously like the $ is given up but still in use, like Prototype in included in the page and jQuery.noConflict() was called (which means $ != jQuery when you're running commands in the console later).
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论