Javascript: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
| Line 3: | Line 3: | ||
get the document by id | get the document by id | ||
* <nowiki>document.getElementById('abcId')</nowiki> | * <nowiki>document.getElementById('abcId')</nowiki> | ||
* alternative: (1) jQuery attr(): <nowiki>$("selector").attr("id");</nowiki><ref>[http://api.jquery.com/attr/ .attr() | jQuery API Documentation]</ref> ([http://jsfiddle.net/planetoid/Ffvwz/ example]) and (2) go to the first step | * alternative: (1) Get the id attribute by using jQuery attr(): <nowiki>$("selector").attr("id");</nowiki><ref>[http://api.jquery.com/attr/ .attr() | jQuery API Documentation]</ref> ([http://jsfiddle.net/planetoid/Ffvwz/ example]) and (2) go to the first step | ||
* parallel naming rules for html elemnt tags ex: <nowiki><input id='checkbox_id1' > & <select id="select_id1"></nowiki> | * parallel naming rules for html elemnt tags ex: <nowiki><input id='checkbox_id1' > & <select id="select_id1"></nowiki> | ||
Revision as of 12:27, 7 February 2013
Javascript approaches to do the same task
get the document by id
- document.getElementById('abcId')
- alternative: (1) Get the id attribute by using jQuery attr(): $("selector").attr("id");[1] (example) and (2) go to the first step
- parallel naming rules for html elemnt tags ex: <input id='checkbox_id1' > & <select id="select_id1">