jquery and user city -
at first, sorry english. question is: have php generated dynamic div, id , image source.. if user click on dynamic div swap img source. script works, swaps div images, not selected div img source. problem? how can swap clicked div img source? can someone, me please?
my script:
<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>
and 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>
use
$(document).ready( function() { $("div.area_map").click( function () { $('img.hoverswap') .css( { "width":"229", "height":"124", "position":"absolute",//to make z-index work "z-index", "9999" }) .attr("src","default/citymap/d5.png"); }); });
also edit css div.area_map
div.area_map{ position:relative; }
this make z-index work relative area_map
Comments
Post a Comment