jQuery Data Type How to - Call predefined function








Question

We would like to know how to call predefined function.

Answer


<!--   w  w w  .  ja  va  2 s  .  c o  m-->
<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
  src='http://code.jquery.com/jquery-1.9.1.js'></script>
<script type='text/javascript'>
$(window).load(function(){
    var link_colour = "red";
    function linkcolor() {
        $("[class='navLink']").css("color",link_colour);
    }
    $(linkcolor);
});
</script>
</head>
<body>
  <a href="#">This is a link!</a> |
  <a href="#" class="navLink">This is a nav link!</a>
</body>
</html>

The code above is rendered as follows: