example: 例:
var o = {};
var e = $('#element');
function doStuff(o) {
if (o.selector) {
console.log('object is jQuery');
}
}
doStuff(o);
doStuff(e);
obviously, the code above works but it's not safe. 显然,上面的代码有效,但不安全。 You could potentially add a selector key to the o object and get the same result. 您可以将选择键添加到o对象并获得相同的结果。 Is there a better way of making sure that the object actually is a jQuery object? 有没有更好的方法来确保对象实际上是一个jQuery对象?
Something in line with (typeof obj == 'jquery') 符合的东西(typeof obj == 'jquery')
上一篇 AdminLTE实现动态菜单项目
下一篇 c#调用直接运行python脚本