JavaScript如何复制控件的样式啊? 如题·我需要将A控件的样式复制给B控件(A控件的样式不定!)请问该如何实现? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 个人觉得可以使用jquery jquery 可以动态的得到样式和添加样式 样式无非就是style和class,当然还有些是继承上级 不过这样也不一定相同因为css有选择器 function getStyle(elem){ return elem.currentStyle || document.defaultView.getComputedStyle(elem, null);}function copyStyle(target, source){ var key, style = getStyle(source); for (key in target.style) { target.style[key] = style[key]; }} for (key in target.style)在每次Key='clip'的时候,都会报参数无效··· function getStyle(elem){ return elem.currentStyle || document.defaultView.getComputedStyle(elem, null);}function copyStyle(target, source){ var key, style = getStyle(source); if (style && style.cssText) { target.style.cssText = style.cssText; } else { for (key in target.style) { try { if (key != 'length' && key != 'cssText' &&style[key]) target.style[key] = style[key]; } catch (e) { continue; } } }} 有些特殊属性需要特别处理,如IE下的filter,LZ自行处理以上代码已在ie/ff/op/sa/ch下测试过了 如何将底部做成漂浮元素,永远都在屏幕的下方,不随屏幕滚动。 JS作用域问题 请问如何用js取得activeX的版本号? JS中字符串的问题 JavaScript代码混淆器,有在线免费版 怎么获得右键目标另存为的事件,各位大虾帮帮忙啊,谢谢了。急!!!!! 各位同行高手,一起来赚点外快吧! javascript的包含文件怎么写? HTML(asp.net)DIV刷新-JQUERY 代码 关于动态表格 class属性的问题 关于任务栏asp托盘图标的问题! JS如何实现这种右下角弹出效果并且滚动页面时无刷新?
因为css有选择器
return elem.currentStyle || document.defaultView.getComputedStyle(elem, null);
}function copyStyle(target, source){
var key, style = getStyle(source);
for (key in target.style) {
target.style[key] = style[key];
}
}
for (key in target.style)
在每次Key='clip'的时候,都会报参数无效···
return elem.currentStyle || document.defaultView.getComputedStyle(elem, null);
}function copyStyle(target, source){
var key, style = getStyle(source);
if (style && style.cssText) {
target.style.cssText = style.cssText;
} else {
for (key in target.style) {
try {
if (key != 'length' && key != 'cssText' &&style[key]) target.style[key] = style[key];
} catch (e) {
continue;
}
}
}
}
以上代码已在ie/ff/op/sa/ch下测试过了