我的 if 语句遇到了问题,一直在检查它们并使用控制台日志来确保当 div 悬停在上面时,我之前声明的变量会更改为某个数字,并且变量确实会更改。
但是由于某种原因,当变量等于某个值时应该触发的语句没有改变,它继续运行第一个 IF,我似乎无法弄清楚为什么,这是我的语法:
$('.work_thumbs').click(function()
{
$('#shadow').fadeTo(200, 0.7);
$('#image_holder').delay(200).show();
if (thumbCheck = 1) {
$('#image_holder').append('<img style="cursor:pointer" class="holder_contents" src="file:///C:/Users/Martin/martin_bodger/images/hi_res_images/ccda_exhibit.jpg">');
} else if (thumbCheck = 2) {
$('#image_holder').append('<img style="cursor:pointer" class="holder_contents" src="file:///C:/Users/Martin/martin_bodger/images/hi_res_images/yourock.png">');
} else if (thumbCheck = 3) {
$('#image_holder').append('<img style="cursor:pointer" class="holder_contents" src="file:///C:/Users/Martin/martin_bodger/images/hi_res_images/visualsynopsisposter.png">' );
} else if (thumbCheck = 4) {
$('#image_holder').append('<img style="cursor:pointer" class="holder_contents" src="file:///C:/Users/Martin/martin_bodger/images/hi_res_images/awesome.jpg">');
} else if (thumbCheck = 5) {
$('#image_holder').append('<img style="cursor:pointer" class="holder_contents" src="file:///C:/Users/Martin/martin_bodger/images/hi_res_images/gameover.png">');
} else {
$('#image_holder').append('<img style="cursor:pointer" class="holder_contents" src="file:///C:/Users/Martin/martin_bodger/images/hi_res_images/whereisbill.png">');
}
});