[jQuery] Re: How to pass loop increment to Jquery
you can use jquery's .each() which is passed the loop index but to be honest the best thing to do is to use a class and replace al that code with $(.show_details) .hover(function() { $(this).show(slow); },function() { $(this).hide(slow); }); --adam On Nov 27, 2:20 pm, Sai Krishna [EMAIL PROTECTED] wrote: Hi, I've my PHP code generating rows using certain loop conditons, And I'd like to show/hide a div overlay on mouseover and mouseout of a text link generated in each row respectively. I wrote the following code. this seems to be show div overlay of last row. That is because I wrote the function in document.ready. I dont think Jquery lets us put javascript in HTML code, So how can I make my code work in such a case? $(document).ready(function(){ var i= $(#count).val(); for(j=0;ji;j++){ var k = #show_details+j; var refer = #show +j; $(k).hide(); $(refer).mouseover(function(){ $(k).show(slow); }); $(refer).mouseout(function(){ $(k).hide(slow); }); } });
[jQuery] Re: How to pass loop increment to Jquery
you'd have to tweak that i kind of missed your structure slightly, but the idea is to just use a class and let jquery handle the iterating... --adam On Nov 27, 2:35 pm, ajpiano [EMAIL PROTECTED] wrote: you can use jquery's .each() which is passed the loop index but to be honest the best thing to do is to use a class and replace al that code with $(.show_details) .hover(function() { $(this).show(slow);},function() { $(this).hide(slow); }); --adam On Nov 27, 2:20 pm, Sai Krishna [EMAIL PROTECTED] wrote: Hi, I've my PHP code generating rows using certain loop conditons, And I'd like to show/hide a div overlay on mouseover and mouseout of a text link generated in each row respectively. I wrote the following code. this seems to be show div overlay of last row. That is because I wrote the function in document.ready. I dont think Jquery lets us put javascript in HTML code, So how can I make my code work in such a case? $(document).ready(function(){ var i= $(#count).val(); for(j=0;ji;j++){ var k = #show_details+j; var refer = #show +j; $(k).hide(); $(refer).mouseover(function(){ $(k).show(slow); }); $(refer).mouseout(function(){ $(k).hide(slow); }); } });
[jQuery] Re: How to pass loop increment to Jquery
thank you Ill try that On Nov 28, 12:36 am, ajpiano [EMAIL PROTECTED] wrote: you'd have to tweak that i kind of missed your structure slightly, but the idea is to just use a class and let jquery handle the iterating... --adam On Nov 27, 2:35 pm, ajpiano [EMAIL PROTECTED] wrote: you can use jquery's .each() which is passed the loop index but to be honest the best thing to do is to use a class and replace al that code with $(.show_details) .hover(function() { $(this).show(slow);},function() { $(this).hide(slow); }); --adam On Nov 27, 2:20 pm, Sai Krishna [EMAIL PROTECTED] wrote: Hi, I've my PHP code generating rows using certain loop conditons, And I'd like to show/hide a div overlay on mouseover and mouseout of a text link generated in each row respectively. I wrote the following code. this seems to be show div overlay of last row. That is because I wrote the function in document.ready. I dont think Jquery lets us put javascript in HTML code, So how can I make my code work in such a case? $(document).ready(function(){ var i= $(#count).val(); for(j=0;ji;j++){ var k = #show_details+j; var refer = #show +j; $(k).hide(); $(refer).mouseover(function(){ $(k).show(slow); }); $(refer).mouseout(function(){ $(k).hide(slow); }); } });
[jQuery] Re: How to pass loop increment to Jquery
I dont know where am I doing mistake here. Could somebody point out? $(document).ready(function(){ $(.show).hover.each( function(){ $(.show_details).hide(slow); }, function(){ $(.show_details).show(slow); }) }); On Nov 28, 1:10 am, Sai Krishna [EMAIL PROTECTED] wrote: thank you Ill try that On Nov 28, 12:36 am, ajpiano [EMAIL PROTECTED] wrote: you'd have to tweak that i kind of missed your structure slightly, but the idea is to just use a class and let jquery handle the iterating... --adam On Nov 27, 2:35 pm, ajpiano [EMAIL PROTECTED] wrote: you can use jquery's .each() which is passed the loop index but to be honest the best thing to do is to use a class and replace al that code with $(.show_details) .hover(function() { $(this).show(slow);},function() { $(this).hide(slow); }); --adam On Nov 27, 2:20 pm, Sai Krishna [EMAIL PROTECTED] wrote: Hi, I've my PHP code generating rows using certain loop conditons, And I'd like to show/hide a div overlay on mouseover and mouseout of a text link generated in each row respectively. I wrote the following code. this seems to be show div overlay of last row. That is because I wrote the function in document.ready. I dont think Jquery lets us put javascript in HTML code, So how can I make my code work in such a case? $(document).ready(function(){ var i= $(#count).val(); for(j=0;ji;j++){ var k = #show_details+j; var refer = #show +j; $(k).hide(); $(refer).mouseover(function(){ $(k).show(slow); }); $(refer).mouseout(function(){ $(k).hide(slow); }); } });
[jQuery] Re: How to pass loop increment to Jquery
jQuery automatically iterates through jQuery collections for you: $(function(){ $(.show).hover(function(){ $(.show_details).hide(slow); }, function(){ $(.show_details).show(slow); }) }); That code will iterate through all DOM objects with a class of 'show' and hide/show all objects with a class of 'show_details'. To get fancy Josh Powell On Nov 27, 1:36 pm, Sai Krishna [EMAIL PROTECTED] wrote: I dont know where am I doing mistake here. Could somebody point out? $(document).ready(function(){ $(.show).hover.each( function(){ $(.show_details).hide(slow); }, function(){ $(.show_details).show(slow); }) }); On Nov 28, 1:10 am, Sai Krishna [EMAIL PROTECTED] wrote: thank you Ill try that On Nov 28, 12:36 am, ajpiano [EMAIL PROTECTED] wrote: you'd have to tweak that i kind of missed your structure slightly, but the idea is to just use a class and let jquery handle the iterating... --adam On Nov 27, 2:35 pm, ajpiano [EMAIL PROTECTED] wrote: you can use jquery's .each() which is passed the loop index but to be honest the best thing to do is to use a class and replace al that code with $(.show_details) .hover(function() { $(this).show(slow);},function() { $(this).hide(slow); }); --adam On Nov 27, 2:20 pm, Sai Krishna [EMAIL PROTECTED] wrote: Hi, I've my PHP code generating rows using certain loop conditons, And I'd like to show/hide a div overlay on mouseover and mouseout of a text link generated in each row respectively. I wrote the following code. this seems to be show div overlay of last row. That is because I wrote the function in document.ready. I dont think Jquery lets us put javascript in HTML code, So how can I make my code work in such a case? $(document).ready(function(){ var i= $(#count).val(); for(j=0;ji;j++){ var k = #show_details+j; var refer = #show +j; $(k).hide(); $(refer).mouseover(function(){ $(k).show(slow); }); $(refer).mouseout(function(){ $(k).hide(slow); }); } });