Skip to content

Instantly share code, notes, and snippets.

@rolandovillca
Last active August 29, 2015 14:21
Show Gist options
  • Save rolandovillca/8fd7d7302ab3c19905af to your computer and use it in GitHub Desktop.
Save rolandovillca/8fd7d7302ab3c19905af to your computer and use it in GitHub Desktop.
DOM HTML PARSING TIPS
$(".txtClass") => getElementsByClassName()
$("#childDiv2 .txtClass") => getElementById(), then getElementsByClassName()
$("#childDiv2 > .txtClass") => getElementById(), then iterate over children and check class
$("input.txtClass") => getElementsByTagName(), then iterate over results and check class
$("#childDiv2 input.txtClass") => getElementById(), then getElementsByTagName(), then iterate over results and check class
//Example:
$('.txtClass');
$('#childDiv2 .txtClass')
$('#childDiv2 > .txtClass')
$('input.txtClass')
$('#childDiv2 input.txtClass')
var obj = document.getElementById("childDiv");
xxx = obj.getElementsByClassName("txtClass");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment