I created this fiddle from code found on Stack, but it is firing an error. Can you help please.
My Fiddle: http://jsfiddle.net/422steve/DVNGc/
Original anser : https://stackoverflow.com/a/13000179/501173
Error I am getting is: TypeError: $allExtended.slideUp() is not a function
js:
$('.holder').on('click','a',function(e){
e.preventDefault();
var $allExtended = $(this).closest('.wrapperdoo').find('.extended'),
$extended = $allExtended.eq( $(this).index() ),
doIt= ($extended.is(':visible')) ? $extended.slideUp() : ($allExtended.slideUp()) ($extended.slideDown());
});
Here is what is going on – in your ternary operation, on the last line, you are trying to call two functions. That is not possible. You need to use an
ifblock. Here is how I rewrote it. I don’t know if you are using thedoItvariable for any purpose, but you will want to check forundefined:— EDIT —
To add the class to the href that is being clicked, just do it like this, in the function:
If you want to remove the class when you are done, do it like this. First, assign the this variable as a global variable (so the
thisvariables don’t get mixed up), like so:Then, in your
slideUp()orslideDown()functions, the second parameter is a callback for when it is completed: