javascript trying to remove all things with certain tags -


i'm trying use javascript remove everyhting button or input tags page... far code removes of them , dont know why. removes 1 checkbox out of many, , 2 buttons (there 3 buttons)

var buttons = document.getelementsbytagname("button"); (var j = 0; j < buttons.length ; j++) {     buttons[j].parentnode.removechild(buttons[j]); }  var checkboxes = document.getelementsbytagname("input"); (var j = 0; j < buttons.length ; j++) {     checkboxes[j].parentnode.removechild(checkboxes[j]); } 

var checkboxes = document.getelementsbytagname("input"); (var j = 0; j < buttons.length ; j++) // use wrong variable here {     checkboxes[j].parentnode.removechild(checkboxes[j]); } 

should be;

for (var j = 0; j < checkboxes.length ; j++)  

regarding undeleted button, maybe it's because it's input type="button" , not <button>?

note document.getelementsbytagname("input"); , delete later inputs, not checkboxes!


may suggest using javascript library jquery? have done 1 line of code no problems:

$('input[type="button"], input[type="checkbox"], button').remove(); 

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -