我必须动态地为元素设置边距。早些时候它是通过以下方式完成的。
var starLink = star.createChild({
tag: 'a',
html: this.values[i],
href: 'javascript:void',
title: this.showTitles ? this.titles[i] : ''
});
// Prepare division settings
if(this.split) {
var odd = (i % this.split);
star.setWidth(sw);
starLink.setStyle('margin-left', '-' + (odd * sw) + 'px');
}
但是现在我更改了我的代码,如下所示。我将如何在此处设置保证金?
var starLink = document.createElement('a');
starLink.href = 'javascript:void';
starLink.title = this.showTitles ? this.titles[i] : '';
starLink.innerHTML = this.values[i];
star.appendChild(starLink);
// Prepare division settings
if(this.split) {
var odd = (i % this.split);
star.setWidth(sw);
starLink.setStyle('margin-left', '-' + (odd * sw) + 'px');
}
starLink.style.marginLeft='10px'或starLink.style.margin = "0px 0px 0px " + xOffset + "px";
怎么样
var starLink = document.createElement('a');
starLink.href = 'javascript:void';
starLink.title = this.showTitles ? this.titles[i] : '';
starLink.innerHTML = this.values[i];
star.appendChild(starLink);
// Prepare division settings
if(this.split) {
var odd = (i % this.split);
star.setWidth(sw);
starLink.style.marginLeft = '-' + (odd * sw) + 'px';
}