1 | <!DOCTYPE html> |
---|
2 | <html xmlns="http://www.w3.org/1999/xhtml"> |
---|
3 | <head> |
---|
4 | <title></title> |
---|
5 | <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js" type="text/javascript"></script> |
---|
6 | <script type="text/javascript"> |
---|
7 | $(function(){ |
---|
8 | |
---|
9 | var itext = $('div')[0].innerText || $('div')[0].textContent; |
---|
10 | var ttext = $('div').text(); |
---|
11 | var s = ""; |
---|
12 | |
---|
13 | if ( itext != ttext ) { |
---|
14 | s += "innerText doesn't match .text()\n"; |
---|
15 | s += ".innerText: "; |
---|
16 | for ( var i=0; i < itext.length; i++ ) |
---|
17 | s += " "+itext.charCodeAt(i).toString(16); |
---|
18 | s += "\n"; |
---|
19 | s += ".text(): "; |
---|
20 | for ( var i=0; i < ttext.length; i++ ) |
---|
21 | s += " "+ttext.charCodeAt(i).toString(16); |
---|
22 | s += "\n"; |
---|
23 | } |
---|
24 | else { |
---|
25 | s += "innerText matches .text()\n"; |
---|
26 | } |
---|
27 | s += "match="+$('div:contains("\u00a0")').length; |
---|
28 | alert(s); |
---|
29 | |
---|
30 | |
---|
31 | }); |
---|
32 | </script> |
---|
33 | </head> |
---|
34 | <body> |
---|
35 | |
---|
36 | |
---|
37 | <div id="test">A A</div> |
---|
38 | |
---|
39 | |
---|
40 | </body> |
---|
41 | </html> |
---|