Reputation: 122
I have this div (<div id="slideshow">
).
In index.php is full.
In the other pages is empty. (I use Joomla, and that is a module).
Now, when is full, it's ok.
But, when it's empty, I want change a css property of next div.
(<div id="slideshow">...</div><section>....</section>
).
Now, I try this code :
alert($("div#slideshow").text() == "");
alert($("div#slideshow").is(':empty'));
The result in all pages are: False , False.
False??? for all?
p.s. for empty I want to say this (<div id="slideshow"></div>
).
Thanks for the answer.
I understood where wrong.
With chrome I saw (<div id="slideshow"></div>
), but copying it as html gave me this:
<div id="slideshow">
</div>
So it's not empty! Now I wonder, how do I proceed?
Upvotes: 0
Views: 471
Reputation: 26730
How about trimming the whitespaces before comparing with an empty string?
$.trim( $('#slideshow').text() ) == ''
Upvotes: 0
Reputation: 3608
Try $("div#slideshow").html()
"In an HTML document, .html() can be used to get the contents of any element" - http://api.jquery.com/html/
"The result of the .text() method is a string containing the combined text of all matched elements" - http://api.jquery.com/text/
Upvotes: 0