I\'m creating a button dynamically using JavaScript and at the same time assigning attributes such as \'ID\', \'type\' etc and also \'onclick\' in order to trigger a functio
Use a function instead of a string. For example,
backButton.onclick = function () { navigate(-1); };