Selecting Elements in the DOM
I am attempting to organize the service offering catalog in a manner that is not alphabetical. I've written some custom Javascript that does allow me to order the Divs based off of a class name. I have this working correctly on a smaller test environment but when I moved it over to the self service portal it seems that i am unable to select the items using the document.getElementsByClassName('cat') selector. I have successfully selected other elements in the DOM for some custom css work that I needed so i believe I am targeting the right elements. I know the script is connecting to the page, i've run a .length on what should be the returned node list and it returns 0.
Does anyone have any thoughts on what the malfunction is. Any help would be greatly appreciated.
Jarrett
Best Answer
-
Martin_Blomgren Customer Ninja IT Monkey ✭✭✭✭Hi,
Could it be a timing issue? Are you sure that the DOM which you're targeting are loaded? Are you using timeouts, mutation observers or another solution for ? Try the code in the browser console and if it works then you know that's the issue.
Is there a reason for go pure JS? Just wondering since Cireson is including jQuery per default.5
Answers
Could it be a timing issue? Are you sure that the DOM which you're targeting are loaded? Are you using timeouts, mutation observers or another solution for ? Try the code in the browser console and if it works then you know that's the issue.
Is there a reason for go pure JS? Just wondering since Cireson is including jQuery per default.