1

I'm trying to use the Jquery.UI library, the issue is, the example given at jqueryui.com is when you pass the effect type, where I want to load a fade out

The JSFiddle is here

http://jsfiddle.net/L3pMG/2/

My code

<div id="effect">
    <h3>Hide</h3>
    <p>Etiam libero neque, luctus a, eleifend nec, semper at, lorem. Sed pede. Nulla lorem metus, adipiscing ut, luctus sed, hendrerit vitae, mi.</p>
</div>

<script>
  $( document ).ready(function() {
         $( "#effect" ).hide( "blind", 1000, callback );
  });
</script>
Ionică Bizău
  • 102,012
  • 80
  • 271
  • 450
MyDaftQuestions
  • 3,763
  • 14
  • 54
  • 106

3 Answers3

5

Because callback is not defined. That's why you get an error and the code can't be run.

You can simply remove it or define the callback function:

$( document ).ready(function() {
    $( "#effect" ).hide( "blind", 1000);
});

or

$( document ).ready(function() {
   var callback = function () { console.log("foo"); }
   $( "#effect" ).hide( "blind", 1000, callback);
});

JSFIDDLE


To learn what the callbacks are, read more here.

Using hide() jQuery method you can pass a function as last parameter. See the documentation.

complete

Type: Function()

A function to call once the animation is complete.

Community
  • 1
  • 1
Ionică Bizău
  • 102,012
  • 80
  • 271
  • 450
4

Your only problem is that callback is not defined, take away that and it works fine.

PixelAcorn
  • 494
  • 7
  • 26
0

If this is truly the entirety of your code, you have to wrap the script in <script> tags before it will do anything.

It also seems to be breaking on "callback" so try removing that argument.

<div id="effect">
    <h3>Hide</h3>
    <p>Etiam libero neque, luctus a, eleifend nec, semper at, lorem. Sed pede. Nulla lorem metus, adipiscing ut, luctus sed, hendrerit vitae, mi.</p>
</div>

<script>
$( document ).ready(function() {
    $( "#effect" ).hide( "blind", 1000 );
});
</script>

See: http://jsfiddle.net/L3pMG/5/

imjared
  • 17,386
  • 3
  • 45
  • 71