jQuery Basic Syntax

jQuery overview:

jQuery is a JS framework (JS class library) that encapsulates traditional JS.

JS commonly used frameworks: jQuery/ExtJS/DWR/Prototype...

Getting started with jQuery:

  1. Introduce jQuery's js file:  <script src="jQuery.js file address"></script> 

  2. jQuery entry function (page loading):  $( function (){ } ); 

     JS page load function:  window.onload = function (){}; 

     Difference: jQuery method: it can be executed multiple times, which is more efficient than window.onload, and executed after the DOM tree of the page is drawn.

      JS method: Execute after the page is loaded.

  3. $ is equivalent to jQuery

js object and jQuery object conversion

  JS object to jQuery object: eg:  var d = document.getElementById("d" ); $(d); // Convert js object d to jquery object. 

  jQuery object to JS object:

    Method 1:  $("#d1")[0]; 

    Method 2:  $("#d1").get(0); 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324814607&siteId=291194637