码迷,mamicode.com
首页 > Web开发 > 详细

jquery07

时间:2017-05-27 11:00:15      阅读:226      评论:0      收藏:0      [点我收藏+]

标签:sem   form   query   struct   find   win   nts   function   array   

<!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

标签:sem   form   query   struct   find   win   nts   function   array   

原文地址:http://www.cnblogs.com/yaowen/p/6911324.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!