This is how you can do this -
var empty = $();
This creates an empty jQuery object:
سؤال
I want to create a jQuery selection that is guaranteed to have no DOM nodes in it. Obviously, I can do this with various hacks, like selecting an id that I know does not exist, but that sucks. How do I do this idiomatically?
المحلول
This is how you can do this -
var empty = $();
This creates an empty jQuery object:
نصائح أخرى
I never been in this situation but you could use this.
$("<div></div>");
or
var empty = {};
console.log($(empty).attr("id"));
console.log($(empty).text());
console.log($(empty));
Output:
undefined
""
{"0": {}, "add": function (e,t){var n=typeof e=="string"?v(e,t):v.makeA..................