Bug Tracker

Ticket #5046: jquery_input_bug.html

File jquery_input_bug.html, 1.2 KB (added by tngd, 11 years ago)
Line 
1<!doctype html>
2<html>
3<head>
4<title>jQuery input[type=text] bug</title>
5<style type="text/css">
6#a, #b { margin: 10px; padding: 10px; border: 1px solid #000; }
7p { font-weight: bold; font-size: large; margin: 0 0 10px 0;}
8small { font-weight: normal; }
9</style>
10
11<script type="text/javascript" src="http://code.jquery.com/jquery-1.3.2.min.js"></script>
12<script type="text/javascript">
13jQuery(function($){
14        $("#a input[type=text]").css("backgroundColor", "green");
15       
16        $("#b input[type=text]:eq(1)").css("backgroundColor", "red");
17});
18</script>
19</head>
20<body>
21
22<div id="a">
23        <p>input[type=text] - backgroundColor: green<br><small>correctly selects elements with type attribute defined</small></p>
24        <input> &lt;input&gt;<br>
25        <input> &lt;input&gt;<br>
26        <br>
27        <input type="text"> &lt;input type="text"&gt;<br>
28        <input type="text"> &lt;input type="text"&gt;<br>
29</div>
30<div id="b">
31        <p>input[type=text]:eq(1) - backgroundColor: red<br><small>incorrectly selects elements without type attribute defined</small></p>
32        <input> &lt;input&gt;<br>
33        <input> &lt;input&gt;<br>
34        <br>
35        <input type="text"> &lt;input type="text"&gt;<br>
36        <input type="text"> &lt;input type="text"&gt;<br>
37</div>
38</body>
39</html>