如何使用JQuery在没有事件的情况下克隆具有数据的元素 [英] How to clone an element with data without events with JQuery

查看:75
本文介绍了如何使用JQuery在没有事件的情况下克隆具有数据的元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用其数据属性克隆一个<select>标记,但不包含其事件.

I want to clone a <select> tag with it's data attribute but without its events.

JQuery官方.clone()api 之后,我知道我可以通过调用而无需数据和事件进行克隆 $('#grolsh').clone(),或执行

Following JQuery Official .clone() api, I understand I can clone without data and events by calling $('#grolsh').clone(), or perform a

$('#grolsh').clone(true)将复制数据和事件.

我想保留数据,但清除与原始项目关联的事件.

I want to keep the data but clear the events associates with the original item.

推荐答案

从1.7版开始, off() 是解除绑定的首选方法:

As from version 1.7, off() is the preferred method for unbinding:

$('#grolsh').clone(true).off();

这篇关于如何使用JQuery在没有事件的情况下克隆具有数据的元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆