Getting the value of an input inside a td for each row with jQuery

Posted by Anne on Stack Overflow See other posts from Stack Overflow or by Anne
Published on 2012-07-08T15:09:38Z Indexed on 2012/07/08 15:15 UTC
Read the original article Hit count: 175

Filed under:

I am still having so many problems with this:

function padTitles() {
    $('tr').each(function () {
        var tds = $(this).find('input'),

        text = tds.filter('[id^="TempRowKey_"]').val(),
        tdToPad = tds.filter('[id^="title_"]'),
        pad;
        if (/0\.0$/.test(text))
            pad = 10;
        else if (/\.0$/.test(text))
            pad = 35;
        else
            pad = 60;
        tdToPad.css('paddingLeft', pad);
    });
}

Note: here is what I was using before. This worked when the value was not inside an input:

var tds = $(this).find('td'),
text = tds.filter('[id^="refKey_"]').text(),

It is supposed to get the Value of the Inputs with id's that start with TempRowKey_ and then use these for padding. But the code does nothing.

Here is my HTML:

<tr id="row_1">
  <td id="tempRowKey_1" >
    <input type="text" size="10" value="1.0.0" class="updatable" id="TempRowKey_1">
  </td>
  <td id="title_1">
     <input id="Title_1" class="updatable" type="text" value="zxxx" size="100" name="item.Title">
  </td>.
  <td ...
</tr>

Is there some way I can test this. I can't get access to anything inside the jQuery block?

© Stack Overflow or respective owner

Related posts about jQuery