作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我喜欢 JQuery 风格的参数解析,并希望在我自己的函数中使用它:
foo( { 'name': 'bob', 'age': 21 });
function foo (param){
alert($.isEmptyObject(param)); //shows true
//now what? :-)
//param.prop('name'); does not work
//$param=$(param); $param.prop('name'); still does not work
//treating it as an array also does not work
}
如何获取我传递的数据?
最佳答案
我不确定你到底在做什么,但这很好用:
foo( { 'name': 'bob', 'age': 21 });
function foo (param){
alert($.isEmptyObject(param)); //shows false
alert(param.name);
}
关于jquery - 在 JQuery 中从 PlainObject 中获取数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8734388/
我喜欢 JQuery 风格的参数解析,并希望在我自己的函数中使用它: foo( { 'name': 'bob', 'age': 21 }); function foo (param){
我收到以下错误: TS2345: Argument of type '"focus"' is not assignable to parameter of type 'PlainObject void
我是一名优秀的程序员,十分优秀!