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
  • 109,027
  • 88
  • 289
  • 474
MyDaftQuestions
  • 4,487
  • 17
  • 63
  • 120

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
  • 109,027
  • 88
  • 289
  • 474
4

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

PixelAcorn
  • 494
  • 8
  • 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
  • 19,492
  • 4
  • 49
  • 72