jQuery表单绑定或索引 [英] jquery form bind or index

查看:84
本文介绍了jQuery表单绑定或索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想指定一个更好的代码,该代码将触发输入广播并执行专用文本字段.

I would like to specify a better code which will trigger a input radio and execute dedicated textfield.

这就是我在说的(抱歉,我对jquery的了解不是那么好,所以请原谅我). 除了我的代码中列出的原始32个调查表之外,我仅发布2个样本.

Here's what i am talking about (sorry im not that very good at jquery so pls pardon me). i post 2 samples only aside from original 32 questionnaires that are listed in my code.

        <table width="817" border="0" cellspacing="1" cellpadding="1">
        <tr>
            <td width="317" height="25">1. &nbsp;Use of adjoining property</td>
            <td width="10" height="25">:</td>
            <td width="480" height="25">
                <input type="radio" name="no1" value="Yes" />Yes
                <input type="radio" name="no1" value="No" />No
            </td>
        </tr>

        <tr class="notes">
            <td height="25" align="right">Notes</td>
            <td height="25">:</td>
            <td height="25">
                <input name="notes1" type="text" id="notes1" size="65" value="" />
            </td>
        </tr>

        <tr>
            <td height="25">3. Access to dirt or paved road</td>
            <td height="25">:</td>
            <td height="25">
                <input type="radio" name="no3" id="radio8" value="Yes" />Yes
                <input type="radio" name="no3" id="radio9" value="No" />No
            </td>
        </tr>

        <tr class="notes">
            <td height="25" align="right">Notes</td>
            <td height="25">:</td>
            <td height="25">
                <input name="notes3" type="text" id="notes3" size="65" value="" />
            </td>
        </tr>
    </table>

我确实尝试创建每个jquery,但想简化代码.

i did try to create each jquery but wanted to simplify the code.

              var notes = $('tr.notes');
            notes.hide();

            $('input[value="Yes"]').click(function () {
                notes.slideDown();
          });

我在这里做了一些研究,但是无法详细说明其结构.我感谢您的帮助.非常感谢.

i did do some research here but can't elaborate the structure. i appreciate your help. many thanks.

推荐答案

这将尝试检测输入单选是否已更改,它将检测是否单击了单击将检查该值并显示注释.

This will try to detect if the input radio is changed, it will detect if the clicked it will check the value and show the notes.

        $('.notes').hide();

        $('input[type="radio"]').change(function () {
            if ($(this).val() == "Yes") {
                 $(this).closest('tr').next('tr.notes').slideDown();
             } else {
                 $(this).closest('tr').next('tr.notes').slideUp();
             }
      });

请检查以下内容:演示

这篇关于jQuery表单绑定或索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆