0x60
0x60

Reputation: 1096

jQuery click slideUp not working

$("#front").click(function () {
    $(this).slideUp();
});

and

<div class="a" id="front">
    <div class="b">
        <h1>...</h1>
        <p>..........</p>
    </div>
</div>

Is there anything wrong with this code? Because it does not work properly.

Upvotes: 0

Views: 4562

Answers (3)

Ben Taliadoros
Ben Taliadoros

Reputation: 9461

One thing that hasn't been mentioned is the callback function, it doesnt really apply here but for those of you who are having this issue and this doesnt solve it make sure you have nothing like a 'remove()' straight after. If you do, use:

$('#ele').slideUp(function(){
    $(this).remove();
});

Like I say, just in case :)

Upvotes: 0

Phil
Phil

Reputation: 11175

What Chuck said.

$(document).ready(function() {
   $("#front").click(function () {
     $(this).slideUp();
  });
});

You can't bind a click on a div that might not exist yet <3

Upvotes: 2

Chuck Morris
Chuck Morris

Reputation: 1148

$(document).ready(function() {
  $("#front").click(function () {
    $(this).slideUp();
  });
});

Upvotes: 2

Related Questions