jQuery basics

19/01/2013 03:01

Include jQuery online (or use your web application path) in <header> tag

<script type="text/javascript" src=" http://jqueryjs.googlecode.com/files/jquery-1.2.6.min.js"></script>

<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>

 

use $ or jQuery in function call:

$( document ).ready( function() { 

  // Your code here

});

 

<input type="Text" name="tbWebsite"/>
< input type="submit" value="Redirect" name="btnSubmit"/>

<a href="#" id="aRedirectLink">SubmitLink</a>

 

 

//select by name and hide/show

jQuery('input[name="tbWebsite"]').hide(); //show();

 

   //Get Textbox value
   var myValue = jQuery('input[name="tbWebsite"]').val();


  //Modify value - adds 123 to the string
   myValue = myValue + "123";


  //Set textbox value
   jQuery('input[name="tbWebsite"]').val(myValue);

 

//Get attribute value
jQuery("#aRedirectLink").attr("href");

 

//Set attribute value

    jQuery("#aRedirectLink").attr("href", newUrl);

 

//Find element with 'MyElementId' asp id (e. g. fjekfjdkfjfkjkk-fkdjfk-fkjdkfMyElementId)

    jQuery("[id*=MyElementId]")

 

//Find specific element with 'MyElementId' asp id (e. g. hidden field)

    jQuery('input:hidden[id$="MyElementId"]')