您的位置:首页 > Web前端 > JQuery

[jquery] jQuery点滴[持续更新]

2015-11-28 04:39 726 查看
001.查看jquery的版本.

$(function(){
console.log($());
//jquery
console.log($().jquery);
});


002.(new Function('return ' + s))() 相当于是用eval来解析一个字符串.

* eval -> 参见 jquery.parser.js
|- (new Function('return ' + s))() 相当于是用eval来解析一个字符串.
// new Function 参考 -> http://www.w3school.com.cn/js/pro_js_functions_function_object.asp // 下面的代码实际是返回一个JSON.类似eval ->
// 参考 http://stackoverflow.com/questions/2449220/jquery-uses-new-functionreturn-data-instead-of-evaldata-to-parse options = (new Function('return ' + s))();


譬如:

var s = 'width:100,height:200,require:true';
var options = (new Function('return ' + s))();
console.log('options:', options);
console.log(options['width']);
//output:
//options: Object {width: 100, height: 200, require: true}
//100


003.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: