Is it possible to exclude a variable of jquery? I have the following code but it is not working.
var container = $ ('# container'); If (container.is (': visible') == wrong) $ (body). Append ('' ;); // I console.log the result and it gives me the wrong container .append ('& lt; p & gt; Test & lt; / p & gt;'); // It does not include
You have the problem that the selector is calculated Is only when you create an object, then container
is still the last store when you last append.
You should reassign the variable:
var container = $ ('# container'); If (container. This (': visible') == incorrect) {$ (body) .append (' ;); Container = $ ('# container'); } Container. Append ('<< & gt; Test & lt; / p & gt;');
But if you do not do more, there is no reason to cache $ ('# container'),
, it's fast to calculate .
No comments:
Post a Comment