1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
| <!DOCTYPE html> <html>
<head> <meta name="author" content="Yeeku.H.Lee(CrazyIt.org)" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title> 工具方法 </title> </head>
<body> <script type="text/javascript" src="../jquery-3.1.1.js"> </script> <script type="text/javascript"> document.writeln("浏览器是否支持创建XMLHttpRequest:" + $.support.ajax + "<br />");
document.writeln("XMLHttpRequest是否有withCredentials:" + $.support.cors + "<br />");
document.writeln("$.trim(' ddd'));的结果是" + $.trim(" ddd") + "<br />");
$.each(["java", "ajax", "java ee"], function (index, value) { document.writeln("['java' , 'ajax' ,'java ee']的第" + index + "个元素为:" + value + "<br />"); });
var grepResult = $.grep(["java", "ajax", "java ee"] , function (value, index) { return value.length > 5; }); document.writeln("['java' , 'ajax' ,'java ee']中数组元素的" + "字符个数大于5的还有:" + grepResult + "<br />");
var mapResult = $.map(["java", "ajax", "java ee"] , function (value, index) { return value + index }); document.writeln("以['java' , 'ajax' ,'java ee']创建的新数组为:" + mapResult + "<br/>");
var div = $("<div>aa<div>"); var divArr = [div, div]; document.writeln("divArr.length的值为:" + divArr.length + "<br />");
document.writeln("$.uniqueSort(divArr).length的结果为:" + $.uniqueSort(divArr).length + "<br />");
var str = "aa"; var strArr = [str, str]; document.writeln("strArr.length的值为:" + strArr.length + "<br />");
document.writeln("$.uniqueSort(strArr).length的结果为:" + $.uniqueSort(strArr).length + "<br />");
var result = $.parseJSON('[{"name":"孙悟空","age":500},' + '{"name":"白骨精","age":21}]'); for (var i = 0, len = result.length; i < len; i++) { document.writeln("第" + i + "个角色的年龄是:" + result[i].name + ",年龄是:" + result[i].age + "<br/>"); } </script> </body>
</html>
|