javascript - JScript Check if element exists and remove it -
i'm trying write simple function in javascript check if element exists in dom , if remove, , if doesn't, append page, far i've got this
if document.contains(document.getelementbyid("submitbutton") { document.getelementbyid("submitbutton").remove(); } else { lastdiv.appendchild(submitbutton); }
(lastdiv div want append div 'submitbutton' to) yet i'm getting error "uncaught referenceerror: myfunction not defined"
any help? i'm aware newbie question, sorry that
there syntax error in code, if
statements require parens
if (document.contains(document.getelementbyid("submitbutton"))) { document.getelementbyid("submitbutton").remove(); } else { lastdiv.appendchild(submitbutton); }
Comments
Post a Comment