Tuesday, 9 December 2014

Get table or gridview textbox value using jquery


//HTML

<table id="GVAnganwadi">
    <tr>
        <td>
            <input type="text" class="firstName" value="foo1">
        </td>
                 <td>
            <input type="text" class="lastName" value="bar1">
        </td>
    </tr>
    <tr>
        <td>
            <input type="text" class="firstName" value="foo2">
        </td>
                <td>
            <input type="text" class="lastName" value="bar2">
        </td>
    </tr>
    <tr>
        <td>
            <input type="text" class="firstName" value="foo3">
        </td>
                 <td>

            <input type="text" class="lastName" value="bar3">
        </td>
    </tr>
    <tr>
        <td>
            <input type="text" class="firstName" value="foo4">
        </td>
                 <td>
            <input type="text" class="lastName" value="bar4">
        </td>
    </tr>
</table>





//Query

$(function () {
        $("[id*=GVAnganwadi] tr:has(td)").each(function () {
            var tt = $(this).children('td:eq(1)');
            var mm = tt.children(0).val()
            alert(tt.children(0).val());
            tt.children(0).css("background-color", "red");

        });

    });

//table


No comments:

Post a Comment

How to highlight selected text in notepad++

  –> To highlight a block of code in Notepad++, please do the following steps step-1  :- Select the required text. step-2  :- Right click...