Question

I am using Jquery 1.3.2 for a script that needs it to run in IE 7/8.

The following code I've made to modify tabSlideOUt v1.3

By William Paoli: http://wpaoli.building58.com is causing a conflict and throwing an "Invalid Argument" error in jquery.

<script type="text/javascript">
$(document).ready(function() {
    $("div#slidetab_1.slide-out-div a.handle").click(function () {
        $("div#slidetab_2.slide-out-div").toggleClass("slide-height", 250) ;
    });
    $("div#slidetab_2.slide-out-div a.handle").click(function () {
        $("div#slidetab_2.slide-out-div.tab2.slide-height").toggleClass("slide-height"); 
    });
});
</script>

It seems that the toggleClass function is causing the error. Does anyone know of another way to code this so I don't have to use toggle?

I'm sorry it seems so vague but I was having trouble posting an example on JS Fiddle.

All I need is an alternative method for toggleClass

Thanks in advance

Cheers

Was it helpful?

Solution

The problem is that you pass 250 as second argument... what is it supposed to do in your code?

From the documentation:

switch A Boolean (not just truthy/falsy) value to determine whether the class should be added or removed.

It seems to have no purpose so I suggest to remove it.

Update: After having a look at the jQuery source code, passing 250 should not throw that error. Nevertheless I suggest to remove it and test it. If it does not work, you have to provide more information (where exactly the error is thrown, etc.).

Alternatively, you use this function to toggle the class:

function toggleClass($element, cls) {
    $element[$element.hasClass(cls) ? 'removeClass' : 'addClass'](cls);
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top