Luke
Luke

Reputation: 2486

jQuery Slide Toggle function not called

I am having trouble with jQuery Slide Toggle.

$(document).ready(function() {
    $("a").click(function() {
    $(this).parent().parent().children("p").Toggle(400);
    return false;
    });
    });

I have a bunch of posts on the page pulled from a database, and they are structured like this (pseudo HTML)

<div post>
    <div float-left location/timeInfo></div>
    <div float-right bandInfo><a>slideToggleLink</a></div>
    <p>theToggledElement</p>
</div>

When I click the link, the jQuery function is not called, but I cannot see what the problem is.

Upvotes: 0

Views: 543

Answers (3)

Sparky
Sparky

Reputation: 98738

You're asking about jQuery "Slide Toggle" but your code is using something called .Toggle(), which does not exist as it is spelled.

It should be .slideToggle() or just .toggle() (note: the lack of capital T in the second). However, there is no sliding/animation with .toggle().

Upvotes: 1

elclanrs
elclanrs

Reputation: 94121

$(this).parent().parent().children("p").Toggle(400);

Bad for performance and Toggle() does not exist.
Replace with:

$('#post').find('p').slideToggle(400);

Upvotes: 1

SLaks
SLaks

Reputation: 887777

jQuery does not have a Toggle() method.

You mean slideToggle().

Upvotes: 1

Related Questions