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

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -