将对象格式的style转换为字符串格式

var style = {
position:'absolute',
background:'red',
width:'2px',
height:'2px',
color:'#fff',
top:x,
left:y,
'z-index':1e5
};
var s = [];
$.each(style,function(i,n){
s.push(i+':'+n);
});
s = s.join(';')
posted @ 2017-01-04 15:39  ~噜啦啦~  阅读(612)  评论(0编辑  收藏  举报