我只花了几个小时来完成以下场景:(全部回归基础)
$('#typo').bind('click' etc ...
Run Code Online (Sandbox Code Playgroud)
我在选择器中输入了一个拼写错误,但jQuery解析了
$('#funny something out there').bind(...
Run Code Online (Sandbox Code Playgroud)
没有任何警告.
当你的选择器什么都没有时,是否有可能告诉jQuery引发错误?
像这样的东西:
$('#typo', alert('Stupid, nothing here! like '+ '#typo))
Run Code Online (Sandbox Code Playgroud)
编辑
我跟我说话了:
$('#typo', alert('Stupid, nothing here! like '+ '#typo))
Run Code Online (Sandbox Code Playgroud)
不是一个解决方案.我必须知道错误在哪里扩展选择器
A. *_*lff 12
您可以使用以下代码段:
更新以照顾上下文
jQuery.debug = true;
$ = function (selector, context) {
if (jQuery.debug && typeof selector === "string" && !jQuery(selector, context).length)
throw new Error("No element found!");
return jQuery.apply(this, arguments);
};
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1824 次 |
| 最近记录: |