Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

jQuery - passing variable 1

Status
Not open for further replies.

jasc2k

Programmer
Nov 2, 2005
113
GB
hi all,

I have a simple javascript function (below) that basically just displays a row in a table
Code:
// This will hide/show the comments on comments table row
function displayRow(rowId){
   // Toggle visibility between none and inline 
    if ((document.getElementById(rowId).style.display == 'none'))
    {
      document.getElementById(rowId).style.display = 'inline';
    } else {
      document.getElementById(rowId).style.display = 'none';
    }
}

What I would like to do is convert this to jQuery and make use of the inbuilt fade function

Code:
$(document).ready(function(){
 $("coc^").blur(function(){
  $(this).fadeIn('medium');
 }
});

The row of the table is named coc*** (***being there are multiple of these rows so need to pass the name of it as a variable to the function, hence rowID in my original code)

I hope you can make sense of this I have just started with jQuery and not sure I understand how to do this type of thing.

Thanks in advance,
James
 
I don't understand what you actually want from us, as you seem to have posted jQuery code.

Perhaps you can tell us what your code doesn't do that you want it to?

Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

Dan's Page [blue]@[/blue] Code Couch:
Code Couch Tech Snippets & Info:
 
hi there,

my original function displayRow works great - I pass the id name of the row I want to show to the function and it changes the style.display setting

I would like to convert this into jQuery code making use of the builtin slide function. However I am unsure about how I pass the id name of the row I wish to show?

any ideas? thanks
 
I would assume you can replace this:

Code:
document.getElementById(rowId).style.display = 'inline';

with this:

Code:
$('#' + rowId).fadeIn('medium');

and if that works, you should be able to figure out the fading out part.

Hope this helps,
Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

Dan's Page [blue]@[/blue] Code Couch:
Code Couch Tech Snippets & Info:
 
Ideal thanks Dan, that was an obvious one - turns out my first problem was missing the # to specify my div!

I have learnt by that mistake!
Thanks

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top