Javascript Useful Resources

Finding out whether the browser is Google Chrome

[javascript]

isChrome = /Chrome/.test(navigator.userAgent) && /Google Inc/.test(navigator.vendor);

[/javascript]

Getting element by class name and changing styles

[javascript]

var arr = document.getElementsByClassName(“ui-datepicker-trigger”);
var arrLength = arr.length
for (i = 0; i < arrLength; i++) {
arr[i].textContent=” “;
arr[i].style.height=”15px”;
arr[i].style.padding=”4px”;
}

[/javascript]

Getting element by id and appending style’s border-collapse

[javascript]

document.getElementById(“table-0”).style.borderCollapse = “collapse”;

[/javascript]

Iterating through children elements

[javascript]

var resultTable = document.getElementById(“table-0”).children;
for(i = 0; i < resultTable.length; i++){
console.log(resultTable[i]);
}

[/javascript]

Get element’s kind&tagname

[javascript]

document.getElementById(“element”).tagName

[/javascript]

String lower case

[javascript]

var strVal = “My Value”;

str lowerVal = strVal.toLowerCase();

[/javascript]

Leave a Reply

Your email address will not be published. Required fields are marked *