0

I found this code, it supposed to find the first cell in the visible row and when I click it the cell is supposed to fadeout or fadein.

I want to adjust the code so that an input button will make this, How can I do this?

$('tr:visible').find('td:first').click(function () {
            $(this).parent().next().fadeToggle()

1 Answer 1

2

I suppose you mean that the function should be executed when you click a specific button.

button.click(function () {
    $('tr:visible').find('td:first').parent().next().fadeToggle()
}

Where 'button' is a variable with a reference to the button you wish to perform the fade.

2
  • 2
    You could simplify the inner line to: $('tr:visible td:first').parent().next().fadeToggle(). Better yet, why go to the td and then .parent(), and not just stay in the tr? So, we could simplify it further: $('tr:visible').next().fadeToggle() Commented May 23, 2012 at 13:34
  • Also, remember to put a ; at the end of the line. Commented May 23, 2012 at 13:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.