var forms = document.getElementsByTagName('form'); for (var i=0; i < forms.length; i++) { if (forms[i].className.search(/ff/) > -1) { var input = document.createElement("input"); input.setAttribute("type", "hidden"); input.setAttribute("name", "ff_token"); input.setAttribute("value", "7f0eb8e66c40990ac20b1009369842b1"); forms[i].appendChild(input); } }