There is a faulty selection rule in the JS.
$(this).closest("dt").find("a").html(text);
This is the line that is supposed to update the selected option text. It will never work, because .closest('x')
traverses up the parents of the initially-called element until it hits root
. Because the element it is looking for is adjacent to one of the parents, it will never find it. Replacing that line with:
$(this).closest("dd").siblings("dt").find("a").html(text);
Means it will find it, by finding the closest parent that the item you seek is adjacent to.