FraserKC
FraserKC

Reputation: 21

Jquery Click trigger another Div - Easy

I think this is probably a pretty easy question, I think I've been staring at this for to long.

Basically, how can I get this 'click' event on one div to trigger the other div to move.

$(".button").click(function () {
  $(.green).toggle("slide", { direction: "left" }, 1000);
});

I know it works like this

$(".button").click(function () {
  $(this).toggle("slide", { direction: "left" }, 1000);
});

But I don't want that .button to slide, I want the .green to slide on click of .button.

Make sense?

http://jsfiddle.net/Hdern/3/

Upvotes: 0

Views: 282

Answers (3)

Kevin Bowersox
Kevin Bowersox

Reputation: 94429

$(".button").click(function () {
  $(".green").toggle("slide", { direction: "left" }, 1000);//Missing quotes
});

Upvotes: 0

dimusic
dimusic

Reputation: 4133

You forgot quotes:

$(".button").click(function () {
  $('.green').toggle("slide", { direction: "left" }, 1000);
});

Upvotes: 1

adeneo
adeneo

Reputation: 318182

This:

$(.green)

should be :

$('.green')

to reference an element by class (or anything else, except variables), you pass a quoted string.

FIDDLE

Upvotes: 4

Related Questions