Home > Web Front-end > JS Tutorial > body text

jquery realizes that the control is unavailable after canceling the check box, but is available when selected (code)

不言
Release: 2018-08-16 12:01:50
Original
1657 people have browsed it

The content of this article is about the jquery implementation of the control being unavailable after canceling the check box. It is available when selected (code). It has certain reference value. Friends in need can refer to it. I hope it will be useful to you. help.

Tag content

<div class="box">
        请编写javascript代码,完成如下功能要求:<br />
        1.取消复选款后,要求促销价格、促销开始结束日期3个控件不可用。<br />
        2.选中复选框后,要求促销价格、促销开始结束日期3个控件可用。
    </div>
    <div class="box">
    
        <table id="table1" class="mytable">
            <tr>
                <td>是否促销:</td>
                <td><input type="checkbox" id="chkPromote" /></td>
            </tr>
            <tr>
                <td>
                    促销价格:
                </td>
                <td>
                    <input type="text" id="txtPromotePrice" />
                </td>
            </tr>
            <tr>
                <td>
                    促销日期:
                </td>
                <td>
                    <input type="text" id="txtStart" />-
                    <input type="text" id="txtEnd" />
                </td>
            </tr>
        </table>
    </div>
Jquery内容
<script>
$(function () {

            $("input[type=text]").attr("disabled", true).val("不可使用");
$("input[type=checkbox]").click(function () {
               
                var $cr = $("input[type=checkbox]");
                if ($cr.is(":checked")) {
                    
                    $("input[type=text]").attr("disabled", false).val("可以使用");
                }
                else {
                    
                    $("input[type=text]").attr("disabled", true).val("不可使用");
                }
            });

        });
</script>
Copy after login

Related recommendations:


The above is the detailed content of jquery realizes that the control is unavailable after canceling the check box, but is available when selected (code). For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!