I have recently taken over development on a project from a programmer that was using multiple jquery versions from 1.3x to 1.6x... Now that I have impl
The version of the toggle
function taking functions as parameters has been removed from last versions, as it's easy to implement it yourself using click
.
For example :
$(document).ready(function() {
var count = 0;
$('div.instruc').click(function() {
if ((count++)%2) {
$('div.instrucContent').slideUp('normal');
$(this).next().slideDown('normal');
} else {
$('div.instrucContent').slideUp('normal');
$("div.instrucContent").hide();
}
});
You can also reintroduce a toggle function with the behavior of the removed function.
Here's a generic replacement :
$.fn.toggleFuncs = function() {
var functions = Array.prototype.slice.call(arguments);
var _this = this.click(function(){
var i = _this.data('func_count') || 0;
functions[i%functions.length].call(_this);
_this.data('func_count', i+1);
});
}
You use it as you would use toggle :
$(document).ready(function() {
$('div.instruc').toggleFuncs(function() {
$('div.instrucContent').slideUp('normal');
$(this).next().slideDown('normal');
}
,function() { $('div.instrucContent').slideUp('normal');
$("div.instrucContent").hide();
});
$('div.ddinstruc').toggleFuncs(function() {
$('div.instrucContent').slideUp('normal');
$(this).next().slideDown('normal');
}
,function() { $('div.instrucContent').slideUp('normal');
$("div.instrucContent").hide();
});
$("div.instrucContent").hide(); //closes all divs on page load
});
The toggle you used is deprecated in jQuery 1.9 see jQuery 1.9 upgrade guide
$('div.instruc').toggle(function() {
$('div.instrucContent').slideUp('normal');
$(this).next().slideDown('normal');
}
,function() { $('div.instrucContent').slideUp('normal');
$("div.instrucContent").hide();
});
Or
$('div.ddinstruc').toggle(function() {
$('div.instrucContent').slideUp('normal');
$(this).next().slideDown('normal');
}
,function() { $('div.instrucContent').slideUp('normal');
$("div.instrucContent").hide();
});