Dave Hill
Dave Hill

Reputation: 81

How to remove the previous element using mootools

I've added a simple span element before an anchor element. I want to remove this span later (no id on either element btw). I'm using mootools 2.x (and my jQuery chops don't seem to be helping much here)

I assumed a simple $(this).prev().remove() would work but not with mootools - anyone help?

the html looks something like this

<span>fail</span><a href="#" onclick="...">link</a>

Upvotes: 2

Views: 5008

Answers (1)

Dimitar Christoff
Dimitar Christoff

Reputation: 26165

within the click handler callback - and don't use onclick, use element.addEvent("click", function() {}); instead:

remove totally: this.getPrevious().destroy();

detatch from dom: this.getPrevious().dispose();

Upvotes: 5

Related Questions