我的Jquery代码应该将表单边框的所有输入字段都转换为蓝色..但这并没有...我到底在哪里出错?

<html>

    <head>
        <title>Form</title>
        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.0/jquery.min.js"></script>
        <script type="text/javascript">
            $(function () {
                alert('Works !');
                $('#provision:text').css('border', '2px solid blue');
            });
        </script>
    </head>

    <body>
        <form id="provision">ESNList:
            <input type="text" id="ESNList" name="ESNList" size="30" />
            <br />ESN Start:
            <input type="text" id="ESNStart" name="ESNStart" size="10" />
            <br />ESN End:
            <input type="text" id="ESNStart" name="ESNStart" size="10" />
            <br />UnitName:
            <input type="text" id="STxName" name="STxName" size="30" />
            <br />Unit Model:
            <select name="STxName">
                <option value="stx2">STX2</option>
                <option value="protopak">Protopak</option>
                <option value="stm3" selected>STM3</option>
                <option value="acutec">Acutec</option>
                <option value="mmt">MMT</option>
                <option value="smartone">Trackpack</option>
                <option value="smartoneb">SmartOneB</option>
                <option value="audi">Acutec</option>
            </select>
            <br />RTU Model Type:
            <select name="rtumodel">
                <option value="globalstar">GlobalStar</option>
                <option value="both">Both</option>
                <option value="comtech">Comtech</option>
                <option value="stmcomtech">STMComtech</option>
            </select>
            <br />
            <input type="submit" value="submit" />
        </form>
    </body>

</html>

最佳答案

这是您所用的正确的JQuery文本选择器:

$('#provision input:text').css('border', '2px solid blue');

文本选择器的官方API文档:http://api.jquery.com/text-selector/

关于javascript - 将所有输入字段更改为蓝色,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/14344772/

10-09 18:14