When the script first load, it will call functionA (This function removes li elements, add new li elements and attach event listener to li parent, which is ul ), I