首页 > 代码库 > jquery07
jquery07
<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>无标题文档</title> <script src="jquery-2.0.3.js"></script> <script> -------------------------------------------------------------- var obj = { name : ‘hello‘ }; var obj1 = new Object(); var obj2 = []; alert($.isPlainObject(obj));//true alert($.isPlainObject(obj1));//true alert($.isPlainObject(obj2));//false -------------------------------------------------------------- var arr = []; var obj1 = {}; function Aaa(){ } var obj = new Aaa(); alert( $.isEmptyObject(obj) );//true alert( $.isEmptyObject(obj1) );//true alert( $.isEmptyObject(arr) );//true function Aaa(){ } Aaa.prototype.aa = 1232; Aaa.prototype.show = function(){}; var obj = new Aaa(); alert( $.isEmptyObject(obj) );//flase for ( name in obj ) { alert(name);//aa show } ------------------------------------------------------------- function Aaa(){ } Aaa.prototype.constructor = Aaa;//系统自动生成的 Aaa.prototype.show = function(){}; for( var attr in Aaa.prototype ){ alert(attr); } -------------------------------------------------------------- $.error(‘这是错误‘);//出错的时候打的log -------------------------------------------------------------- var str = ‘<li></li><li></li><script><\/script>‘; console.log($.parseHTML(str,document,true)); --------------------------------------------------------------- $(‘<li></li>‘) --> $.parseHTML(str) 单标签------------>context.createElement( parsed[1] ) 多标签------------>jQuery.buildFragment( [ data ], context, scripts ) $.parseHTML(); --------------------------------------------------------------- var str = ‘<li></li><li></li>‘; console.log($.parseHTML(str)); /*[li, li] 0: li 1: li length: 2 __proto__: Array(0) */ var str = ‘<li></li><li></li><script><\/script>‘; console.log($.parseHTML(str,document,true)); /* [li, li, script] 0: li 1: li 2: script length: 3 __proto__: Array(0) */ </script> </head> <body> </body> </html>
<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>无标题文档</title> <script src="jquery-2.0.3.js"></script> <script> var str = ‘{"name":"hello"}‘; alert($.parseJSON(str).name); //JSON.parse和eval,eval也可以转json,eval可以解析任何类型的字符串,安全性和性能不如JSON.parse JSON.stringify();//把json变成字符串 </script> </head> <body> <p id="someElement"></p> <p id="anotherElement"></p> <script> var xml = "<rss version=‘2.0‘><channel><title>RSS Title</title></channel></rss>", xmlDoc = $.parseXML( xml ),//文档document对象, $xml = $( xmlDoc ), $title = $xml.find( "title" ); // Append "RSS Title" to #someElement $( "#someElement" ).append( $title.text() ); // Change the title to "XML Title" $title.text( "XML Title" ); // Append "XML Title" to #anotherElement $( "#anotherElement" ).append( $title.text() ); ------------------------------------------------------------------- <parsererror>错误的信息</parsererror> ActiveXObject ------------------------------------------------ function Aaa(){ this.defaults = { show : $.noop }; } Aaa.prototype.init = function(opt){ $.extend( this.defaults , opt ); }; </script> </body> </html>
<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>无标题文档</title> <script src="jquery-2.0.3.js"></script> <script> ---------------------------------------------------------------------- function test() { jQuery.globalEval( "var newVar = true;" ) var newVar1 = true; } test(); alert( newVar ); alert( newVar1 ); ---------------------------------------------------------------------- function test(){ var i = eval; i(‘var a = 1‘); eval(‘var b = 2‘); window.eval(‘var c = 3‘); alert( "s"+a ); alert( "s"+b ); alert( "s"+c ); } test(); alert( a );//1 alert( b );//buxing alert( c );//3 -------------------------------------------------------------- margin-top -> marginTop -ms-transform -> msTransform -moz-transform -> MozTransform ---------------------------------------------------------------- $(function(){ alert($.nodeName(document.documentElement,‘html‘));//true alert($.nodeName(document.body,‘body‘));//true alert( document.body.nodeName );//BODY }); ---------------------------------------------------------------- var arr = [‘a‘,‘b‘,‘c‘,‘d‘]; arguments childNodes getElementsByTagName var json = { name : ‘hello‘ , age : 20 }; $.each(json , function(i,value){//下标 每一个值 alert(value); return false; }); $.each(arr , function(i,value){//下标 每一个值 alert(value); return false;//只执行一次 }); </script> </head> <body> </body> </html>
jquery07
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。