Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save misraX/ad1cdfc4bf05381de250720b99d0635a to your computer and use it in GitHub Desktop.
Save misraX/ad1cdfc4bf05381de250720b99d0635a to your computer and use it in GitHub Desktop.
function showElementsOnClient(elements){
// Select Elements.
var selectedElements = document.querySelectorAll(elements);
// looping through the querySelectorAll NodeList[selectedElements_lenght]
for (i in selectedElements){
// defining selectedElements into the countedElements
var countedElements = selectedElements[i].innerText;
// checking if the countedElements are not undefined
if (typeof countedElements != "undefined"){
// write the defiend countedElements
document.write("<p>" + "Pargraph innerText is: " + countedElements + "</p>" + "</br>");
}
else{
// throw the undefined values
console.log("can't read undefined value");
}
// end for
}
// end function
}
// calling the function
showElementsOnClient("elements")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment