removing an appended element using javascript/closure?

I currently have a click event in place that when selected appends a search box to .header, this is done using google closure. My problem now is if I click a close button I want to remove this appended element. I know using jQuery requires only .remove() but Im unsure how to achieve this in closure or vanilla js. Can anyone advise how I can do this?

Current code:

if(goog.dom.getElementsByClass('pe')){
    var searchCtn = goog.dom.getElementsByClass('search');     
    var headerWrapper = goog.dom.getElementByClass('header');     
    goog.dom.append(headerWrapper,searchCtn); 
} 

var closeButton = goog.dom.getElement('close');
    goog.events.listen(closeButton, goog.events.EventType.CLICK, function() {
    console.log('Remove appended');
}, false, this); 

171 thoughts on “removing an appended element using javascript/closure?”

  1. Thank you for the auspicious writeup. It if truth be told was once a entertainment account it.
    Glance complicated to far delivered agreeable from you!
    By the way, how can we keep in touch?

    Reply
  2. I do not know if it’s just me or if perhaps everybody else experiencing problems with
    your blog. It appears as though some of the text on your posts
    are running off the screen. Can someone else please
    comment and let me know if this is happening
    to them as well? This could be a problem with my internet browser because I’ve had this
    happen before. Thanks

    Reply
  3. Its like you learn my thoughts! You appear to understand a lot approximately
    this, such as you wrote the guide in it or
    something. I believe that you just could do with some percent to pressure the message house a bit,
    but instead of that, that is magnificent blog. An excellent
    read. I’ll certainly be back.

    Reply
  4. Hello there! This article couldn’t be written much better!
    Going through this article reminds me of my previous roommate!
    He constantly kept talking about this. I’ll forward this
    post to him. Pretty sure he’s going to have a great
    read. I appreciate you for sharing!

    Reply
  5. Right here is the right blog for anyone who wishes to understand
    this topic. You realize a whole lot its almost tough to argue with you (not
    that I really will need to…HaHa). You definitely put a new
    spin on a subject that’s been written about for many years.
    Great stuff, just great!

    Reply
  6. Hi there would you mind letting me know which web host you’re utilizing?
    I’ve loaded your blog in 3 completely different internet browsers and
    I must say this blog loads a lot quicker then most. Can you recommend a good internet hosting provider at a
    fair price? Thanks a lot, I appreciate it!

    Reply
  7. I’d like to thank you for the efforts you’ve put in penning this blog.
    I really hope to see the same high-grade blog posts from you later on as well.
    In truth, your creative writing abilities has inspired me to get my own, personal
    blog now 😉

    Reply
  8. Its like you learn my thoughts! You seem to know a lot about
    this, such as you wrote the ebook in it or something.
    I think that you simply can do with some percent to power the
    message house a little bit, however instead of that,
    that is great blog. An excellent read. I’ll certainly be back.

    Reply
  9. An impressive share! I’ve just forwarded this onto a coworker
    who was doing a little research on this. And he in fact bought me dinner simply because
    I found it for him… lol. So allow me to reword
    this…. Thank YOU for the meal!! But yeah, thanx for spending
    the time to talk about this subject here on your web page.

    Reply

Leave a Comment