我想使用Y.StyleSheet樣式元素。如何使用Y.StyleSheet樣式
這是我當前如何做它,它工作正常:http://jsfiddle.net/AxUMD/47/
document.documentElement.className += ' js';
Y.one('#techsolutionsCheckBox input[type=checkbox]').on('change', function (e) {
var target = e.currentTarget,
techSBox = Y.one('.box'),
techSBlueBox = document.getElementById('techsolutions');
colourBlue = "#cee4f2",
colourWhite = "#ffffff";
if (target.get('checked')) {
techSBox.removeClass('hidden');
techSBlueBox.style.backgroundColor = colourBlue;
techSBlueBox.style.width = "380px";
techSBlueBox.style.height = "100px";
} else {
techSBox.addClass('hidden');
techSBlueBox.style.backgroundColor = colourWhite;
techSBlueBox.style.width = null;
techSBlueBox.style.height = null;
}
});
,但是這是我想做到這一點:http://jsfiddle.net/AxUMD/57/ 但它不工作,我以爲它會。
document.documentElement.className += ' js';
Y.one('#techsolutionsCheckBox input[type=checkbox]').on('change', function (e) {
var target = e.currentTarget,
techSBox = Y.one('.box'),
techSBlueBox = Y.one(Y.DOM.byId("#techsolutions")),
changesChecked = { background-color : '#cee4f2', width : '380px', height : '100px' },
changesUnChecked = { background-color : '#ffffff', width : null, height : null },
currentStyle = techSBlueBox.getStyle('cssText');
if (target.get('checked')) {
techSBox.removeClass('hidden');
techSBlueBox.setStyle('cssText', Y.StyleSheet.toCssText(changesChecked, currentStyle));
} else {
techSBox.addClass('hidden');
techSBlueBox.setStyle('cssText', Y.StyleSheet.toCssText(changesUnChecked, currentStyle));
}
});
任何幫助將不勝感激。
三江源