views:

38

answers:

1

Hi,

I would like to check if my paragraph tag is empty using Jquery. Meaning without content.

$(function() {
    $("#popupdialog").dialog();
});

HTML

<div id="popupdialog"> 
<p></p> </div>

Separate Instants.

<div id="popupdialog" title="Basic dialog"> 
<p>This is the default dialog which is useful for displaying information. The dialog window can be moved, resized and closed with the 'x' icon.</p>

If the popupdialog is without content. I would like the dialog box to set as autoOpen: false. How should I do it?

+2  A: 
if ($('#popupdialog > p').is(':empty')) { 
    // we're empty. do stuff.
}
x1a4
A link to the documentation, just in case you need it http://api.jquery.com/empty-selector/
Chubas
$(function() { if ($('#popupdialog > p').is(':empty')) { $("#popupdialog").dialog({autoOpen: false}); } else{ $("#popupdialog").dialog(); }});Tried this code, doesn't work
Gidiyo
Need more info, then.
x1a4
@x1a4 mentioned code should work. @Gidiyo can you please check in the firebug or put an alert to check whether you are able to reach inside the if loop which you have put? that can give you some idea of where the issue is.
Raghav Khunger
Got it to work with normal website. Just that doesn't work in Joomla.
Gidiyo