0

I have the following script to remove a jquery button:

       var elem = $('[symbol="GOOG"][exchange="NASDAQ"][class="remove-button"]') //select the item
       (elem.parentNode).remove();

The relevant html is:

<div id="GOOG" symbol="GOOG" exchange="NASDAQ" class="stockButton">
        GOOG
        <span symbol="GOOG" exchange="NASDAQ" class="remove-button">
             x
        </span>
</div>

However, nothing happens and I'm not sure why? I do something similiar on click elsewhere which works fine. The above two javascript lines I call manually in the code. Thanks.

user1357015
  • 11,168
  • 22
  • 66
  • 111

1 Answers1

1

Change the remove line to this:

$(elem).parent().remove();
Sai
  • 2,068
  • 19
  • 24
  • why do I need another "$", when var elem already equals to a "$(...". This trips me up every time! – user1357015 Feb 24 '14 at 21:05
  • 1
    @user1357015 The $ represents the jQuery Function, and is actually a shorthand alias for **jQuery**. It is typically used as a selector. This link might help you. [SO](http://stackoverflow.com/questions/1150381/what-is-the-meaning-of-sign-in-javascript) – Sai Feb 24 '14 at 21:11