var thisLiAttr = { role: 'presentation' };
var thisLi = $('<li/>', thisLiAttr)
http://www.w3school.com.cn/jquery/core_jquery.asp#syntax2
用法 2 :设置属性和事件
语法
jQuery(html,props)
对于 jQuery 1.4,我们可以向第二个参数传递一个属性映射。该参数接受能够传递给 .attr() 方法的属性的超集。此外,可以传递任意的事件类型,并可以调用下面的 jQuery 方法:val, css, html, text, data, width, height, or offset.
注意,Internet Explorer 不允许你创建 input 元素并改变其类型;您必须使用例如 "<input type="checkbox" />" 来规定类型。
实例
创建一个 <input> 元素,同时设定 type 属性、属性值,以及一些事件。
$("<input>", {
type: "text",
val: "Test",
focusin: function() {
$(this).addClass("active");
},
focusout: function() {
$(this).removeClass("active");
}
}).appendTo("form");
你可以打印下这两个对象:
$('
thisLi [0]就是
<li role="presentation"></li>