How to call function in JQuery

How to call function in JQuery

JQuery is most loved and widely used rich library to call functions and perform actions unobtrusively. You want to learn how to call functions in JQuery. It’s very simple than how we call in JavaScript. JQuery is wrapper over JavaScript.

JQuery call function example.

Let’s start looking at the code below.

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js" >
</
script> <script type="text/javascript" language="javascript"> $("document").ready(function(){ $("#div1").html("Hello div1"); $("#div2").html("Hello div1"); $("#div3").html("Hello div1"); $("#div4").html("Hello div1"); }); </script>

Description: I have html containing several div elements namely div1,div2,div3 and div4. At design time I have no value in them. However, when JQuery do call document ready event, it attaches html content to them.

On document ready we are finding those div by their ID. 

Syntax to get element by ID 

$(“#div1”)

# symbol in above code specifies JQuery to get element by it’s ID. Isn’t it a clean and simple to use rather than finding document.getElementById() function in Javascript? Yes, it is.

Complete Example To call Function in JQuery

<html>
<head>
    <title>JQuery call function example</title>

    <script src=http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js></script>

    <script type="text/javascript" language="javascript"> 
   
       $("document").ready(function(){
       
           $("#div1").html("Hello div1");
           $("#div2").html("Hello div1");
           $("#div3").html("Hello div1");
           $("#div4").html("Hello div1");
           
            
        });
        
    </script>

</head>
<body>
    <div id="div1"></div>
    <div id="div2"></div>
    <div id="div3"></div>
    <div id="div4"></div> 
</body>
</html>
Learning JqueryBasics of jqueryJquery CallBack TutorialJQuery SlideJQuery add/remove Class DynamicallyJquery Trim StringJQuery Animate Div Height and WidthGoogle JQuery CDNJquery Dropdown Selected ValueHow to check image is loaded using JQueryJQuery Form With Validation

Author

My name is Satalaj, but people call me Sat. Here is my homepage: . I live in Pune, PN and work as a Software Engineer. I'm former MVP in ASP.net year 2010.
Disclaimer: Views or opinion expressed here are my personal research and it has nothing to do with my employer. You are free to use the code, ideas/hints in your projects. However, you should not copy and paste my original content to other web sites. Feel free to copy or extend the code.
If you want to fight with me, this website is not for you.
 

I'm Satalaj.