MoinMoin Logo
  • Comments
  • Immutable Page
  • Menu
    • Navigation
    • RecentChanges
    • FindPage
    • Local Site Map
    • Help
    • HelpContents
    • HelpOnMoinWikiSyntax
    • Display
    • Attachments
    • Info
    • Raw Text
    • Print View
    • Edit
    • Load
    • Save
  • Login

Navigation

  • Start
  • Sitemap
Revision 2 as of 2014-07-09 21:39:05
  • Javascript
  • jquery

jquery

The purpose of jQuery is to make it much easier to use JavaScript on your website.

http://jquery.com/

DOM ready

Toggle line numbers
   1 $(document).ready(function(){
   2 //......
   3 });
   4 //-----------
   5 $(document).ready(readyx);
   6 function readyx(){
   7 // called on DOM ready
   8 }

Find element by id

Toggle line numbers
   1 // element id id1234
   2 var x1234 = $("#id1234");

Find elements by class

Toggle line numbers
   1 // element with class classsdf
   2 var elements = $(".classsdf");
   3 elements.each(  eachHandler  );
   4 
   5 function eachHandler(index,element){
   6 console.log(index + ' ' +element);
   7 }

Get or set select dropdownlist selected value

Toggle line numbers
   1 $("#dropdown").val(); //get value
   2 $("#dropdown").val('asd'); //select value asd
   3 

.attr( attributeName )

Returns String Get the value of an attribute for the first element in the set of matched elements.

.text()

Returns String Get the combined text contents of each element in the set of matched elements, including their descendants.

html()

Returns String Get the HTML contents of the first element in the set of matched elements.

.append( content [, content ] )

Returns jQuery Insert content, specified by the parameter, to the end of each element in the set of matched elements.

.empty()

Returns jQuery Remove all child nodes of the set of matched elements from the DOM.

jQuery.get( url [, data ] [, success ] [, dataType ] )

Returns jqXHR Load data from the server using a HTTP GET request.

Toggle line numbers
   1 $.get( "test.cgi", { name: "John", time: "2pm" } )
   2   .done(  function( data ) {
   3     alert( "Data Loaded: " + data );
   4   });
   5 
   6 $.ajax({
   7   url: url,
   8   data: data,
   9   success: success, // function(data, textStatus,jqXHR )
  10   error: error , // function( jqXHR, textStatus, errorThrown )
  11   dataType: dataType // text, html, xml, json, jsonp, and script.
  12 });
  • MoinMoin Powered
  • Python Powered
  • GPL licensed
  • Valid HTML 4.01