js怎样清除点击事件

JavaScript020

js怎样清除点击事件,第1张

可以设置点击事件函数为空函数,即“onclick=function(){}”。

也可以移除事件指派或移除onclick事件属性,jquery当中可以用unbind方法移除。

1. 重写touchstart touchmove等事件,让这些事件什么也不做

例如: document.ontouchstart = funciton(){ return false}

2. 取消事件冒泡的行为

3 把你的触屏事件删除掉

vue.js移除绑定的点击事件的方法:可以用 v-on 指令监听 DOM 事件:<div id="example"> <button v-on:click="greet">Greet</button></div>绑定了一个单击事件处理器到一个方法 greet。下面在 Vue 实例中定义这个方法:var vm = new Vue({ el: '#example', data: {name: 'Vue.js' }, // 在 `methods` 对象中定义方法 methods: {greet: function (event) { // 方法内 `this` 指向 vm alert('Hello ' + this.name + '!') // `event` 是原生 DOM 事件 alert(event.target.tagName)} }})// 也可以在 JavaScript 代码中调用方法vm.greet() // ->'Hello Vue.js!'