Skip to main content

Bug Tracker

Side navigation

#15109 closed bug (notabug)

Opened May 27, 2014 03:32AM UTC

Closed May 28, 2014 02:57PM UTC

bug about Attribute Equals Selector [name="value"]

Reported by: wxpxzdj Owned by: wxpxzdj
Priority: undecided Milestone: None
Component: unfiled Version: 1.11.1
Keywords: Cc:
Blocked by: Blocking:
Attachments (0)
Change History (5)

Changed May 27, 2014 04:02AM UTC by rwaldron comment:1

owner: → wxpxzdj
status: newpending

Please provide a test case using jsFiddle, as described on http://bugs.jquery.com

Changed May 27, 2014 04:08AM UTC by wxpxzdj comment:2

status: pendingnew

jquery 1.11.1

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <script src="http://code.jquery.com/jquery-1.11.1.js" type="text/javascript"></script>
    <script  type="text/javascript">
        $(function () {
            $("#btn").click(function () {
                $("#number").text($("input[name='code'][value='1']").length);
                $("input[name='code'][value='1']").css("background", "#FF6633");
                return false;
            });
        });
    </script>
</head>
<body>
    <form id="form1">
    <div>
        <input type="text" name="code" value="1" /><br/>
        <input type="text" name="code" value="1" /><br/>
        <input type="text" name="code" value="" /><br/>
        <input type="text" name="code" value="" /><br/>
        <input type="button" value="find the 1" id="btn" /><br/>
        find:<label id="number"></label>
    </div>
    </form>
</body>
</html>

jquery 1.8.1

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <script src="http://code.jquery.com/jquery-1.8.3.js" type="text/javascript"></script>
    <script  type="text/javascript">
        $(function () {
            $("#btn").click(function () {
                $("#number").text($("input[name='code'][value='1']").length);
                $("input[name='code'][value='1']").css("background", "#FF6633");
                return false;
            });
        });
    </script>
</head>
<body>
    <form id="form1">
    <div>
        <input type="text" name="code" value="1" /><br/>
        <input type="text" name="code" value="1" /><br/>
        <input type="text" name="code" value="" /><br/>
        <input type="text" name="code" value="" /><br/>
        <input type="button" value="find the 1" id="btn" /><br/>
        find:<label id="number"></label>
    </div>
    </form>
</body>
</html>

Changed May 27, 2014 04:14AM UTC by rwaldron comment:3

status: newpending

No, you need to put this code into a fiddle on jsfiddle and post the link back here.

Changed May 27, 2014 05:00AM UTC by wxpxzdj comment:4

_comment0: http://jsfiddle.net/BqPs5/2/ \ [[BR]] \ (PS:I'm sorry......)1401167943979017
status: pendingnew

http://jsfiddle.net/BqPs5/3/

(PS:I'm sorry......)

Changed May 28, 2014 02:57PM UTC by gibson042 comment:5

resolution: → notabug
status: newclosed

This is working exactly as expected. [value='1'] selects elements with a "value" ''attribute'' equal to 1, regardless of the current "value" ''property'' (e.g., as set by .val or .prop).

http://jquery.com/upgrade-guide/1.9/#attr-versus-prop-