Thursday, November 20, 2014

Introduction to JQuery


     JQuery is a well known JavaScript library that helps to develop rapid applications with the help of the large library involves in it. You can download the JavaScript file of JQuery or can use it with a CDN that means you just use the JavaScript file hosted on the network. We'll use JQuery with CDN at our examples. Just go to the page and use the latest release's CND which is "<script src="//"></script>" at the time of this writing. When you use CDN your visitors previously downloaded a copy of the same CDN can reuse it without downloading it again. You can also use other CDN providers like google and microsoft. We see using google CDN in our example.


     In the below example, I show both the standart JavaScript syntax and the syntax of JQuery with which you define a function on a html element in the $(document).ready(function() { ... }; without calling the onClick of that element. Here we define a myLink_onClick() function for the myLink html element and call that function with onClick property of the element. On the other hand, with the JQuery we just define $('#myLink').click(function() { ... }); in the ready function and no need to call onClick anymore. We have a text, a button and a link in the example, when you click on link the text set with the "val("")" syntax of the JQuery. Also when you click on button both link click methods are fired. The run order of the methods is first the old JavaScript method and then the new JQuery method if you click on the link. However if you fire the click of link with the button's click, the order is reversed.

 <script src=""></script>
<!-- for google CDN use
  <script src=""></script> 
   $(document).ready(function() {
     $('#myLink').click(function () { 
        var myText = $('#myText');
         return true;
   $('#myLinkReset').click(function () { 
  var myText = $('#myText');
         return true;
   function myButton_onClick() {
   function myLink_onClick() {
   <input type="text" id="myText">
   <input type="button" id="myButton" onClick="myButton_onClick()" value="click me">
   <a id='myLink' href='#' onClick="myLink_onClick()"> click me </a>
   <a id='myLinkReset' href='#' > reset </a>

The screen will look like the following.

Introduction to JQuery
Figure 1

Introduction to JQuery
Figure 2


     With the help of JQuery you can develop faster applications. It is easier to develop applications since it has a large library. JQuery also has ajax support.

You can download the source code from here.

1 comment:

  1. After importing your part design, you'll obtain an online quote that features manufacturing analysis to help enhance part manufacturability. Within your quote, might also|you can even} MATERNITY BRAS modify amount and material and see value modifications in real-time. Further particulars, such as undercuts, or any function that wants additional tooling, will increase mould price. Surface finish of the core and cavity of moulds additional influences price.