问题1:我有三个变量。className 引用一个字符串。back 包含内容,link 包含一个 html 字符串。我正在尝试将内容分配给任何变量 className 引用。
var back = "test";
var className = "link1";
var link1 = '<div id="back" class="gohome"></div><div class="link3"></div><div class="link4"></div>';
因为下面的代码似乎对我不起作用
$(className) = className + back;
问题 2:下面的代码似乎没有更新 prevClass 包含的任何变量的 CSS。
$('[id*="back"]').each(function(){
$('.' + prevClass).css({'left': '-123px'});
$('.' + prevClass).css({'top': '430px'});
$('.' + prevClass).css({'width': '123px'});
$('.' + prevClass).css({'height': '44px'});
<script type="text/javascript">
var back = "";
var prevClass = "start"
var className = "Broken";
start = '<div id="back" class="gohome"></div><div class="link1"></div><div class="link2"></div>';
gohome = '<div class="gohome"></div><div class="start"></div>';
link1 = '<div id="back" class="gohome"></div><div class="link3"></div><div class="link4"></div>';
link2 = '<div class="gohome"></div>';
link3 = '<div id="back" class="gohome"></div><div class="link5"></div><div class="link6"></div>';
link4 = '<div class="gohome"></div><div class="link7"></div><div class="link8"></div>';
link5 = '<div class="gohome"></div><div class="link2a"></div><div class="link10"></div>';
link6 = '<div class="gohome"></div><div class="link7"></div><div class="link11"></div>';
link6a = '<div class="gohome"></div><div class="link7"></div><div class="link11"></div>';
link7 = '<div class="gohome"></div><div class="link6a"></div><div class="link9"></div>';
link8 = '<div class="gohome"></div><div class="link2a"></div><div class="link10"></div>';
link9 = '<div class="gohome"></div><div class="link10a"></div>';
link10 = '<div class="gohome"></div><div class="link12"></div><div class="link13"></div>';
link10a = '<div class="gohome"></div><div class="link12"></div><div class="link13"></div>';
link11 = '<div class="gohome"></div><div class="link10a"></div>';
link12 = '<div class="gohome"></div><div class="link12"></div><div class="link13"></div>';
link13 = '<div class="gohome"></div><div class="link14"></div><div class="link15"></div>';
link14 = '<div class="gohome"></div>';
link15 = '<div class="gohome"></div><div class="link16"></div><div class="link17"></div>';
link16 = '<div class="gohome"></div>';
link17 = '<div class="gohome"></div><div class="link18"></div><div class="link19"></div>';
link18 = '<div class="gohome"></div>';
link19 = '<div class="gohome"></div><div class="link20"></div><div class="link21"></div>';
link20 = '<div class="gohome"></div>';
link21 = '<div class="gohome"></div>';
$(document).on('click', '.inter [class]', function () {
className = this.className;
$('[id*="back"]').each(function(){
$('.' + prevClass).css({'left': '123px'});
$('.' + prevClass).css({'top': '430px'});
$('.' + prevClass).css({'width': '123px'});
$('.' + prevClass).css({'height': '44px'});
});
back = '<div class="' + prevClass + '"></div>';
$('.' + className).html(back);
prevClass = className;
$('.inter').fadeTo(250, 0.25, function () {
$('.inter').html(window[className]);
$('.inter').css({'background-image': 'url("' + className + '.png")'});
$('.inter').fadeTo(250, 1.00);
});
});
</script>