Search code examples
javascripthtmlmootools

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.


Solution

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

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