Sunday, December 9, 2012

jQuery: Dim an Entity and Hide it

Make sure you call the jQuery library before running any jQuery functions. Either library version is fine, Google or jQuery Foundation. The following shows the code to dim the myDiv to 0.1 opacity within 500ms. After that, hide the DIV:

$('#myDiv').fadeTo(500, 0.1, function() {
  $('#myDiv').css({visibility: "hidden"});

If you straight away animate the opacity to 0 without hiding the DIV, the DIV will stay there although it is not visible nor it is hidden. If the DIV is another layer, it is recommended to hide it or it could cause some interactivity problem as it may cause the links below the DIV not being able to interact with the user.

No comments:

Post a Comment