Jquery Course

Callback Functions are functions that are added as arguments to other function.
JavaScript instructions are executed line by line, very fast. With effects, the next line of code can be run even though the effect is not finished. This can create errors. To prevent this, you can use a callback function.
A callback function is executed after the current effect is completely finished.
In jQuery, the callback functions are used alot in animation effects.

- Example (see the comments in code):
<button id="test">Click</button>
<script type="text/javascript">
// when click on the "test" button, it is executed a callback function (as parameter to click() method)
$('#test').click( function() {
 // this function hides the clicked element, then displays an alert message
 // the alert() instruction it is added into an anonymous callback function (passed as seccond parameter)
 $(this).hide("slow", function(){
 alert('Hi :)');
 });
});
</script>
- Demo:
• To see the difference, here is the same example, but with the alert() instruction added after the hide() method (not into a callback function).
<button id="test">Click</button>
<script type="text/javascript">
// when click on the "test" button, it is executed a callback function (as parameter to click() method)
$('#test').click( function() {
 // this function hides the clicked element, and displays an alert message (almost in the same time)
 $(this).hide("slow");
 alert('Hi :)');
});
</script>
- Demo:

Daily Test with Code Example

HTML
CSS
JavaScript
PHP-MySQL
Which tag defines the clickable areas inside the image map?
<map> <img> <area>
<img src="image.jpg" usemap="#map1">
<map name="map1">
  <area shape="rect" coords="9, 120, 56, 149" href="#">
  <area shape="rect" coords="100, 200, 156, 249" href="#">
</map>
Which CSS property defines what is done if the content in a box is too big for its defined space?
display overflow position
#id {
  overflow: auto;
}
Click on the event which is triggered when the mouse is positioned over an object.
onclick onmouseover onmouseout
document.getElementById("id").onmouseover = function(){
  document.write("Have Good Life");
}
Indicate the PHP variable that contains data added in URL address after the "?" character.
$_SESSION $_GET $_POST
if(isset($_GET["id"])) {
  echo $_GET["id"];
}
jQuery Callback Functions

Last accessed pages

  1. The Four Agreements (1616)
  2. Read Excel file data in PHP - PhpExcelReader (96683)
  3. Courses Web: PHP-MySQL JavaScript Node.js Ajax HTML CSS (137552)
  4. Add Tag to Selected Text in textarea with JavaScript (3193)
  5. Mixins (216)

Popular pages this month

  1. Courses Web: PHP-MySQL JavaScript Node.js Ajax HTML CSS (241)
  2. Read Excel file data in PHP - PhpExcelReader (84)
  3. The Four Agreements (73)
  4. PHP Unzipper - Extract Zip, Rar Archives (72)
  5. The Mastery of Love (60)
Chat
Chat or leave a message for the other users
Full screenInchide