起初,抱歉我的英語。 我的問題是:我有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: