funbinod Posted September 11, 2014 Share Posted September 11, 2014 (edited) I was trying to change the style of a row while I mouseover it. the rows are generated from MySQL_query and while loop. but it worked for just first row. here is what I tried--- <style>.mouseover { background-color: #CCC; color: #FCC; border:none; width:13em; height:1.5em }</style><?.................................while($row = mysqli_fetch_array($result)) { echo "<tr style='text-align:center; background-color:#c99; height:2em;' id='acrow'>"; echo "<td style='width:500px;'>" . $row['name'] . "</td>"; echo "<td style='width:125px;'>" . $row['ac_type'] . " (".$row['ac_id'].")</td>"; echo "<td style='width:200px;text-align:right'>" . number_format(($row['ob']),2,'.',',') . "</td>"; echo "<td style='width:25px;'><a href="acregister.php?aid=$row[aid]&m=e" class=slink>Edit</a></td>"; echo "<td style='width:50px;'><a href="creport.php?aid=$row[aid]" class=slink>Report</a></td>"; echo "</tr>"; }?>........................<script>$(document).ready(function(e) {//sregister $("#acrow").mouseover(function(e) { $("#acrow").addClass('mouseover'); }) $("#acrow").mouseout(function(e) { $("#acrow").removeClass('mouseover'); })})</script> please suggest me what I did mistake or there is some better option or this is not the good practice... Edited September 11, 2014 by funbinod Link to comment Share on other sites More sharing options...
srinivas g Posted September 11, 2014 Share Posted September 11, 2014 Hi funbinod , can u explain me actually what u want to do ... so that i may help u Link to comment Share on other sites More sharing options...
srinivas g Posted September 11, 2014 Share Posted September 11, 2014 first check properly about "$result" query.. Link to comment Share on other sites More sharing options...
funbinod Posted September 11, 2014 Author Share Posted September 11, 2014 what I want is not suggestions about queries..... I want suggestion on changing the style of rows onMouseOver and onMouseOut. check the jquery function at the bottom Link to comment Share on other sites More sharing options...
Ingolme Posted September 11, 2014 Share Posted September 11, 2014 It's probably better to use the CSS :hover pseudo-class instead of having Javascript do it. Link to comment Share on other sites More sharing options...
funbinod Posted September 11, 2014 Author Share Posted September 11, 2014 wow! great! it worked. thank u for the suggestion............ Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now