jQuery中的克隆样式? [英] Clone style in jQuery?

查看:108
本文介绍了jQuery中的克隆样式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个名为spn1<span>,它具有内联+ CSS文件中的某种样式.

I have a <span> called spn1, which has some style from inline + CSS file.

我还有一个名为spn2<span>.

如何将spn1完成样式克隆到spn2中?

How can I clone spn1's complete style into spn2?

我希望spn2的外观与spn1完全一样.

I want spn2 to look exactly (in style) like spn1.

推荐答案

看看这个线程: https://stackoverflow.com/a/6416527/541827
想法是将样式的所有属性从一项复制到另一项

Take a look at this thread: https://stackoverflow.com/a/6416527/541827
The idea is to copy all the style's properties from one item to another

或者仅使用 jquery.copycss.js 插件,答案就基于此.
用法:

Or just use the jquery.copycss.js plugin, the answer is based on.
Usage:

$('#some-element').copyCSS('#another-element');  // copy all styles
$('#some-element').copyCSS('#another-element', ['top', 'left']);  // copy just top and left
$('#some-element').copyCSS('#another-element', null, ['top', 'left']);  // copy everything except top and left

这篇关于jQuery中的克隆样式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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