How to pass a dynamic DIV ID to a function in JQuery
Hi all,
I got a problem with passing dynamic DIV ID.
I was doing some a php page which retrieved data from database and put into according DIV tag like this:
<DIV id="variabl1">msg1</td>;
Since there were tens of records in the table in database, the result would become:
<DIV id="variabl1">msg1</td>;
<DIV id="variabl2">msg2</td>;
...
<DIV id="variabl100">msg100</td>;
I got a JQuery script to show a specific message when a user moved his mouse over a DIV,
say if he moved his mouse over DIV ID 1, a msg would pop up showing message.
The script is as follows:
- <script language="javascript" type="text/javascript">
- $(function(){
- $(document).ready(function()
- {
- $("#140").mouseover(function(e)
- {
- var height = $('#popup_div1').height();
- var width = $('#popup_div1').width();
- leftVal=e.pageX-(width/2)+"px";
- topVal=e.pageY-(height/2)+"px";
- $('#popup_div1').css({left:leftVal,top:topVal}).show();
- });
- $("#Div1").mouseout(function()
- {
- $('#popup_div1').hide();
- });
- });
- });
- </script>
I dont now how to modify the script for a hundred DIV with different IDs.
Could you help me modify the script so that each DIV can pass its ID to the script above.
Please help.