Wednesday, February 22, 2012

To find radio button text and value

$("#btnTest").click(function () {

            $("#divTestFunction").find("table").find("tr").each(function () {
                $(this).find("input:radio").each(function () {
                    if ($(this).attr("checked") == true) {                      
                        alert(jQuery.trim($(this).parent().text()));
                    }
                });
            });
 });

-----------------------------------------

<div id="divTestFunction">
        <table>
            <tr>
                <td>
                </td>
                <td>
                    <input type="radio" name="rbtnTest" />Demo Text
                </td>
            </tr>
        </table>
    </div>
    <input type="button" id="btnTest" value="Test" />

No comments:

Post a Comment