Created
April 5, 2009 20:12
-
-
Save pwood/90520 to your computer and use it in GitHub Desktop.
JavaScript to show all elements of a specified class.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function changeDisplayAll(className, state) { | |
var editXPath = "//*[@class='" + className + "']"; | |
var editElements = new Array(); | |
var editElementsCount = 0; | |
var editXPResult = document.evaluate(editXPath, document, null, XPathResult.ANY_TYPE, null); | |
var thisEditClass = editXPResult.iterateNext(); | |
while (thisEditClass) { | |
editElements[editElementsCount++] = thisEditClass | |
thisEditClass = editXPResult.iterateNext(); | |
} | |
for (var i=0; i < editElementsCount; i++) { | |
editElements[i].style.display = state; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment