ethan
ethan

Reputation: 13

How to remove “onclick” with Mootools

I want to click other element to remove attribute on click with element a ;

I used html like this:

<a href="#" data-value="all"  class="search-item" onclick="showCat(this)">全部商品</a>

And JS like this:

$$(".search-item").remove("click",showCat);

it is not working. How can I fix those problems.

Upvotes: 1

Views: 240

Answers (3)

Sergio
Sergio

Reputation: 28845

MooTools API for removing attributes is Element:removeProperty, and you can use like this:

$$(".search-item").removeProperty("onclick");

Upvotes: 1

WladimirStroganov
WladimirStroganov

Reputation: 176

You can remove element's attribute like this:

$$(".search-item").setProperty("onclick", null);

Upvotes: 0

Rajesh Meena
Rajesh Meena

Reputation: 21

Ethan use jQuery library

  jQuery('.search-item').removeProp('onClick').unbind('click')

Upvotes: 0

Related Questions