【发布时间】:2016-12-06 04:06:39
【问题描述】:
我正在使用 dragula.js,并在 mycode 中使用 ondrop 事件,
drake.on('drop', function (el) {
console.log(el); //result <div>foo bar</div>
var n = typeof(el); //return object
var x = el.indexOf("test"); //error TypeError: el.indexOf is not a function(…)
// do another code
})
我想检查"test" 是否存在于el 参数上,但出现错误。谢谢。
【问题讨论】:
-
n 是否返回适当的类型?
-
不,我知道它返回对象类型,正如@skyline 所说,它不能使用
indexOf -
为什么不使用 console.log(n)
-
代码旁边的注释来自console.log(n)。与 console.log(x) 相同,结果为错误。
标签: javascript dragula