jQuery - 单击链接将所有类从一个元素复制到另一个元素
(参见jsfiddle示例)
当单击“.link_to_rule_them_all”时,我想将所有“.link_to_rule_them_all span”类复制到#box中,并在每次单击之间清除“#box”。
我的示例代码和解释在这里http://jsfiddle.net/znCmq/2/
可以看到我不知道这个的js..有什么想法吗?呃..
(see jsfiddle example)
When the ".link_to_rule_them_all" is clicked i would like to copy all the '.link_to_rule_them_all span' classes into #box and clear the '#box' between every click.
my example code and the explanation is here http://jsfiddle.net/znCmq/2/
As you can see i have no idea about the js of this.. any ideas? eh..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
实例:http://jsfiddle.net/moeishaa/3t33d/
live example : http://jsfiddle.net/moeishaa/3t33d/
使用这个:
使用 null href 而不是哈希是正确的形式。
Use this:
It's proper form to use a null href instead of a hash.
首先,您可以像这样将侦听器直接添加到跨度中:
然后您可以将类属性添加到 DIV
好吧,让我们尝试一下
如果您想将跨度类添加为文本:
First of all, you can add the listener directly to the span like this:
Then you can add the class attribute to the DIV
Ok let's try this then
If you wanna add the span class as TEXT: