Bug Tracker

Ticket #4058: index.html

File index.html, 1.5 KB (added by ecentinela, 11 years ago)

chrome find selector

Line 
1<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
2    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4<head>
5    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6    <script type="text/javascript" src="jquery.js"></script>
7    <script type="text/javascript">
8        $(function() {
9            var container = $('#container');
10
11            var containerSelecteds = function() {
12                return container.find('ul.selected');
13            };
14
15            var bodySelecteds = function() {
16                return $('ul.selected');
17            };
18
19            var select = function(nodes) {
20                containerSelecteds().removeClass('selected');
21
22                nodes.addClass('selected');
23
24                // the container html show me that the element has the class "selected"
25                alert(container.html());
26
27                // webkit (chrome and safari) says that there are no elements inside of <container> with the class "selected"
28                alert(containerSelecteds().length);
29
30                // but the element exists in the dom, and it has the classname "selected" !!
31                alert(bodySelecteds().length);
32            };
33
34            var element = $('<ul class="someclass"><li>MyText</li></ul>').appendTo(container);
35            select(element, false);
36        });
37    </script>
38</head>
39<body>
40    <div id="container" style="border:1px solid #ccc;height:300px;width:300px"></div>
41</body>
42</html>