Tuesday, February 10, 2015

Javascript Element Diagnostic Function

function elementResearch(elementType, searchVal) {
 // e.g. elementType = 'input'
 console.log(" elementResearch begin in element type " + elementType);
 $('body').find(elementType).each(
           function(unusedIndex, child) {
               if(child.value==searchVal && searchVal!='') { 
                  console.log("___ELEMENTRESEARCH FOUND THE VALUE YOU ARE TESTING!!!___"); 
                  console.log("the child.name you are wanting is: " + child.name); 
                  $(child).each(function() {
               $.each(child.attributes, function() {
               if(this.value!='hidden') {
                         console.log( elementType + " || attribute name:" +  this.name + " || attribute value:" +this.value);
                 }
                 }); // each attr
              }); // each child
            } // if big match
                  if(searchVal=='') {
                  $(child).each(function() {
                  $.each(child.attributes, function() {
                  console.log( elementType + " || attribute name:" +  this.name + " || attribute value:" +this.value);
               }); // each attr  
                }); // each child
                } // if searchVal==""
       }); // each input
} // function



elementResearch('input', 'TEST');