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>
时间: 2025-01-20 03:25:59

jquery07的相关文章

jQuery07源码 (3803 , 4299) attr() prop() val() addClass()等 : 对元素属性的操作

var nodeHook, boolHook, rclass = /[\t\r\n\f]/g, rreturn = /\r/g, rfocusable = /^(?:input|select|textarea|button)$/i; jQuery.fn.extend({ attr: function( name, value ) { //遍历this //arguments.length > 1,jQuery.attr(this[i],name,value),返回this //arguments

微信公众平台网页开发实战--1.微信分享一个网页到朋友圈

对微信的JSSDK进行封装一下,创建一份类似的文件结构,增加index.html与shareApi.js文件,结构如图3.3所示. 图3.3  3.2节文件结构 另外,提醒读者一下,wxJSSDK.js文件的JSSDK环境配置中,需要更改一下配置参数,代码如下: 01 jsApiList: [ // 其他代码略 02 "onMenuShareTimeline", 03 "onMenuShareAppMessage", 04 "onMenuShareQQ&q