ambuli
asked on
Iterate through all divs within a div
Hi there,
I need to iterate through a Div which contains other divs.
I want to find all the ones with ID that starts with "ReportDataDivID". The following code works, but I am iterating via all the DOM. I want to just go over the testDiv which will be passed to this function. How can I efficiently do this. Thank you.
I need to iterate through a Div which contains other divs.
I want to find all the ones with ID that starts with "ReportDataDivID". The following code works, but I am iterating via all the DOM. I want to just go over the testDiv which will be passed to this function. How can I efficiently do this. Thank you.
var __ensureVisible = function(testDiv){
var divs = document.getElementsByTagName("div");
for(var i = 0; i < divs.length; i++){
var regexp = new RegExp('^' + "ReportDataDivID");
if(regexp.test(divs[i].id)){
$("#" + divs[i].id).show();
}
}
};
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hi,
the main jQuery API is here:
http://api.jquery.com/
Further selector choices:
http://api.jquery.com/category/selectors/attribute-selectors/
Thanks for the points
Rainer
the main jQuery API is here:
http://api.jquery.com/
Further selector choices:
http://api.jquery.com/category/selectors/attribute-selectors/
Thanks for the points
Rainer
ASKER