renisenbb
asked on
Javascript: replacing document.all()
I have to replace the line below:
var cells = document.all("cell_1_0");
Does this return an array of elements of all the elements with id=cell_1_0 ?
Using JQuery: can i simply replace this line with:
var cells = $("*[id^=cell_1_0]");
Does this return an array of elements of all the elements that start with id=cell_1_0 ?
The reason i have the ^ is just to include more ids that start with cell_1_0
Is there a pure Javascript way of doing this also?
var cells = document.all("cell_1_0");
Does this return an array of elements of all the elements with id=cell_1_0 ?
Using JQuery: can i simply replace this line with:
var cells = $("*[id^=cell_1_0]");
Does this return an array of elements of all the elements that start with id=cell_1_0 ?
The reason i have the ^ is just to include more ids that start with cell_1_0
Is there a pure Javascript way of doing this also?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
According to Microsofts page here
https://msdn.microsoft.com/en-us/library/ms537434%28v=vs.85%29.aspx
and here
https://msdn.microsoft.com/en-us/library/bg182625%28v=vs.85%29.aspx
Deprecated in favour of getElementByID
If not working post your html so we can see in context.
https://msdn.microsoft.com/en-us/library/ms537434%28v=vs.85%29.aspx
and here
https://msdn.microsoft.com/en-us/library/bg182625%28v=vs.85%29.aspx
Deprecated in favour of getElementByID
If not working post your html so we can see in context.
ASKER
I found out that the following returns an HTMLCollection object.
var cells = document.all("cell_1_0");
And this returns an array object. So i'm not sure if it's compatible with the above.
var cells = $("*[id^=cell_1_0]");
Does this return an HTMLCollection object too?
var elements = document.querySelectorAll(