This question shows research effort; it is useful and clear
2
This question does not show any research effort; it is unclear or not useful
Bookmark this question.
Show activity on this post.
要素を見つけようとして間違いを犯し、のようなタイプミスをしたとしましょう$('lsdkfj')。jQueryが空の配列を返す代わりに、コンソールにのようなエラーメッセージを返したいのですが
"The selector 'lsdkfj' cannot be found"。これを行うための最良の方法は何ですか?
var oldInit = $.fn.init;
$.fn.init = function(selector, context, rootjQuery) {
var result = new oldInit(selector, context, rootjQuery);
if (result.length === 0)
console.info("jQuery call has no elements!", arguments);
return result;
};