gpt4 book ai didi

javascript - 需要有关鼠标按下所选图像的背景颜色的帮助。并删除所选其他图像的背景

转载 作者:行者123 更新时间:2023-11-28 09:05:15 24 4
gpt4 key购买 nike

//这使我在 img 上的背景颜色为黄色,但如果我选择另一个 img,它将不会删除第一个选择的 img 上的背景颜色:

$('img').mousedown(function() {
var $selectedDiv = $(this).parent();
var divId = $selectedDiv.attr('id');
currentCol = divId [1];
currentRow = divId [3];
$("#r"+currentCol+"c"+currentRow).css("background", "Yellow");
});

最佳答案

这就是我要做的:

$('img').mousedown(function() {
$('img').css('background', ''); // This will set back the background colour to whatever colour you need image to be.
// You can now process the current image.
var $selectedDiv = $(this).parent();
var divId = $selectedDiv.attr('id');
currentCol = divId [1];
currentRow = divId [3];
$("#r"+currentCol+"c"+currentRow).css("background", "Yellow");
});

关于javascript - 需要有关鼠标按下所选图像的背景颜色的帮助。并删除所选其他图像的背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26741510/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com