起初,抱歉我的英语。 我的问题是:我有PHP生成的动态股利,与ID和图像源..如果用户点击动态股利其交换IMG源。 我的脚本工作,但它交换所有div图像,但没有选择div img源码。 问题在哪里?我如何交换点击div img源码?有人能帮助我吗?jquery和用户城市
我的脚本:
<script> (function($) {
$(document).ready(function() {
$("div.area_map").click(function() {
$('div[id^=grass]').each(function(div) {
$('img.hoverswap').css("width","229");
$('img.hoverswap').css("height","124");
$('img.hoverswap').attr("src","default/citymap/D5.png");
$('img.hoverswap').css("z-index", "9999")
});
});
}) (jQuery);
</script>
和DIV:
<div class="area_map" id="grass
<?php echo $k+$st_x/2; ?>"
style='cursor:pointer; width:118px; height:51px; position:absolute;
left:<?php echo $st_x; ?>px;
top:<?php echo $st_y; ?>px;'>
<img src="default/citymap/Zale2.png" name="table" border="0"
usemap="#tableMap" class="hoverswap"
style='cursor:pointer; z-index:-300; width:118px; height:51px;'/>
</div>
And div: