1 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
---|
2 | <html xmlns="http://www.w3.org/1999/xhtml"> |
---|
3 | <head> |
---|
4 | <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> |
---|
5 | <script type="text/javascript"> |
---|
6 | function countStuff(){ |
---|
7 | // Results for IE 7 only (tested in IE tester and IE8 compatibility mode) |
---|
8 | alert($('a[name="thename"]').length); // shows 1, correct - 'a' element ok |
---|
9 | alert($('div[class="theclass"]').length); // shows 1, correct - 'div' element by attribute:class ok |
---|
10 | alert($('div[name="thename"]').length); // shows 0, should be 1 !!!: |
---|
11 | |
---|
12 | alert($('.theclass[name="thename"]').length); //shows 1, should be 2 !!! - div element excluded |
---|
13 | alert($('.theclass').filter('[name="thename"]').length);// shows 2, correct - using filter selects both elements |
---|
14 | } |
---|
15 | </script> |
---|
16 | </head> |
---|
17 | |
---|
18 | <body> |
---|
19 | <div name='thename' class='theclass'>Content in a div</div> |
---|
20 | <a href='#' name='thename' class='theclass'>Content within a link</a> |
---|
21 | <p><a href='#' onclick='countStuff()'>CLICK HERE - Count stuff</a></p> |
---|
22 | </body> |
---|
23 | </html> |
---|