ULs don’t have a name attribute, but you can reference the ul by tag name.
Try replacing line 3 in your script with this:
var sub = cat.getElementsByTagName("UL");
ULs don’t have a name attribute, but you can reference the ul by tag name.
Try replacing line 3 in your script with this:
var sub = cat.getElementsByTagName("UL");