Jquery 单击时替换图像
我有两个表,第一个(id=符号)包含3个图像。 第二个表(id=tbl)将包含各种不同的图像 我试图用从符号表中选择的图像替换单元格的图像(在本例中,假设它是顶行右侧的第二个单元格) 我想在将鼠标悬停在符号表上时突出显示这些图像。 单击时,我希望用正在单击的图像替换另一个表中的图像,并更改包含所选图像的表单元格的背景色。 我还需要能够识别单击了哪个图像(或单元格) 这是我现在的小提琴,不太好用 谢谢你的帮助Jquery 单击时替换图像,jquery,html,css,Jquery,Html,Css,我有两个表,第一个(id=符号)包含3个图像。 第二个表(id=tbl)将包含各种不同的图像 我试图用从符号表中选择的图像替换单元格的图像(在本例中,假设它是顶行右侧的第二个单元格) 我想在将鼠标悬停在符号表上时突出显示这些图像。 单击时,我希望用正在单击的图像替换另一个表中的图像,并更改包含所选图像的表单元格的背景色。 我还需要能够识别单击了哪个图像(或单元格) 这是我现在的小提琴,不太好用 谢谢你的帮助 <table id="symbols"> <tr> <td
<table id="symbols">
<tr>
<td ><img src="http://icons.iconarchive.com/icons/deleket/soft-scraps/32/Button-Blank-Yellow-icon.png"/></td>
<td >
<img src=" http://icons.iconarchive.com/icons/deleket/soft-scraps/32/Button-Blank-Blue-icon.png"/>
</td>
<td class="items p1 p3"><img src="http://icons.iconarchive.com/icons/yootheme/social-bookmark/32/social-google-buzz-button-icon.png"/></td>
</tr>
</table>
<table border="1" id="tbl">
<tr>
<td ></td>
<td bgcolor=#000000 >
<img src="http://icons.iconarchive.com/icons/deleket/soft-scraps/32/Button-Blank-Red-icon.png"/>
</td>
<td class="items p1 p3"></td>
</tr>
<tr>
<td bgcolor=#000000 ></td>
<td class="items p1"></td>
<td class="items p3" bgcolor=#000000 ></td>
</tr>
<tr>
<td class="piece" id="p1" ></td>
<td bgcolor=#000000 ></td>
<td class="piece" id="p3" ></td>
</tr>
</table>
这是一种方法
虽然我宁愿使用id或类非常感谢。是否有一种方法可以让我也得到图像名称或ID或图像点击?谢谢
var imgs = $('img');
imgs.click(function () {
var img = $(this);
$("#tbl").find("tbody tr").eq(2).children().first().attr('src', img);
});
var imgs = $('img');
imgs.click(function(){
var img = $(this);
$("#tbl").find("tbody tr:eq(0) td:eq(1) img").attr('src', img.attr('src'));
//The cells we can move our image to.
});