Access all input/text boxes in td element

NealR

I'm using a table that has a hyperlink with the wording of "Edit" in the last column. In the first two columns are two text boxes with their readonly values set to true.

When the user clicks on the "Edit" link I want to change the readonly property to false and the wording of the hyperlink to "Save".

After attaching a click function to the hyperlink, how do I access the two text boxes? My first thought was to check the .parent element for input and go from there, but that didn't work. I also tried looking for the closest td element and doing a .find on any input but I couldn't get that to work either (although I may be looping through the inputs incorrectly.

Here's what I have so far:

    $('.editException').click(function () {
        if ($(this).text() == 'Save') {

        } else {
            //Change text of hyperlink (this is working)
            $(this).text('Save');

            //My two attempts at making the text boxes non-readonly
            $(this).parent('input').attr('readonly', false);
            $(this).closest('td').find('input').each(function () {
                this.readOnly = false;
            });
      });
Barmar

Try this:

$(this).closest('tr').find('input').attr('readonly', false);

You need to go all the way up to the TR, because the inputs are in different columns. You don't need .each(), because .attr() works on all the elements that are selected.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Access all input/text boxes in td element

From Dev

Find all td elements on click of their th element

From Dev

Cant access all children of element?

From Dev

Saving data from multiple inputtext boxes created by a loop in jsf

From Dev

Same space between 2 inputText boxes using JSF and CSS

From Dev

Select all <td> elements that "belong" to specific <th> element

From Dev

Select all <td> elements that "belong" to specific <th> element

From Dev

How to extract all td's text content from an element in the array?

From Dev

Get the sum of all the previous td elements and save it in the last td element - jQuery

From Dev

Clear all check boxes

From Dev

Select all checked boxes

From Dev

Playbooks applied to all boxes

From Dev

Querying all the records based on multiple combo boxes from a form, in MS Access

From Dev

Change TD Element in jQuery

From Dev

How to click on a <Td> element

From Dev

element inside td tag

From Dev

Binding Checkbox to td element

From Dev

Selecting td element in a tr

From Dev

Get next element in td

From Dev

Uncheck all Check boxes in Android

From Dev

Selecting All Select Boxes (Javascript)

From Dev

Check all check boxes in AngularJS

From Dev

Append TD('s) after td element

From Dev

TD element is a inline element or block level element?

From Dev

Rerender all h:inputText fields with same id inside h:dataTable

From Dev

JavaScript remove element from multiple select boxes

From Dev

How to add a comment using comment boxes in Access?

From Dev

How to add a comment using comment boxes in Access?

From Dev

add td element to tr with id