How to use $ or jQuery keyword differently in JQuery coding


After some days with jquery, i got a doubt like "can we customize $ or jQuery keyword in jquery coding". We can do that using JQuery.

It is very simple to do conversion of $ with your custom name.

Main Code:

              var JQueryExampleCode = $; //(or) jQuery

              JQueryExampleCode(function () {
                  JQueryExampleCode('body').css("background-color", "Silver}");
                  alert('JQueryExampleCode.blogspot.com'); 
              });


Complete Code:


<html>
<head>
    <title></title>
          <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
          <script type="text/javascript">
              var JQueryExampleCode = $; //(or) jQuery

              JQueryExampleCode(function () {
                  JQueryExampleCode('body').css("background-color", "Silver}");
                  alert('JQueryExampleCode.blogspot.com'); 
              });
          </script>
</head>
<body>
This is body content. 
</body>
</html>
 

Output:

How to use $ or jQuery keyword differently in JQuery coding
How to use $ or jQuery keyword differently in JQuery coding

Post a Comment

Complete posts