Creating a rollover with PHP and Javascript -
i've read ton of question , answers rollovers using php , javascript , can't figure out why isn't working. have php code:
$rollover = '$("#' . $godname . '").mouseenter(function() { $("#' . $godname . '").attr("src","img/gods/god_cards/dark/' . $godimage . '2.png"); }); $("#' . $godname . '").mouseleave(function() { $("#' . $godname . '").attr("src","img/gods/god_cards/' . $godimage . '.png"); });';
$godname
, $godimage
variables retrieved through query database. wanted use code cut down on amount i'd have write create rollover on 50 images, create function every image retrieved in query. wanted stick in javascript tag so:
<script type="text/javascript"> <?php echo $rollover; ?> </script>
but doesn't work. , i've tried doing , without echo , no version of whatever i've found on here or anywhere else works. when echo out text looks fine, spits out should i'm not sure why javascript doesn't seem accepting php. help?
do check if html dom ready? using jquery, can use:
<script type="text/javascript"> $(function(){ <?php echo $rollover; ?> }); </script>
Comments
Post a Comment