[英]jQuery: DOM Elements: Attributes: query & create
I have a few questions about jQuery, relating to attributes: 我对jQuery有一些与属性有关的问题:
It seems possible because when I open up the JS debugger in Google Chrome using CTRL-Shift-J, and click on a DOM element in the elements pane, I can see all of the attributes of the element without having to ask for them by name. 这似乎是可能的,因为当我使用CTRL-Shift-J在Google Chrome中打开JS调试器,然后在元素窗格中单击DOM元素时,可以看到该元素的所有属性,而不必按名称要求。
The other guys are right that you should use clone
- but if you want to list the attributes, you can do it like so: 其他人是对的,您应该使用
clone
-但是,如果要列出属性,可以这样进行:
for(attr in $('#selector')) {
console.log(attr);
}
I don't think you can create a new css rule, but you can do pretty much the same by attaching css to a selector: 我认为您无法创建新的CSS规则,但可以通过将CSS附加到选择器来执行几乎相同的操作:
$('#selector').css({
display: 'block'
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.