#createNewAccount does not stand for a variable but for an ID attribute. To
check if the element exist you can check if it contains a value, if it does
by default or check if it contains any HTML inside the tags.

On Thu, Jun 19, 2008 at 4:10 PM, [EMAIL PROTECTED] <
[EMAIL PROTECTED]> wrote:

>
> Hi all. I've done some searching, but being new to this am struggling
> to find what I'm after even though I'm sure the answer is simple.
>
> I'm in at the deep end working with a webapp that uses JQuery, I
> presume with various plugins for form validation. I have some code as
> follows:
>
> jQuery(document).ready(function() {
>
>                if ($("#createNewAccount").is(":checked")){
>                        jQuery('div.showHideAccountDetails').show();
>                }else{
>                        jQuery('div.showHideAccountDetails').hide();
>                }
> }
>
> But in some situations the variable 'createNewAccount' does not exist,
> as the form element is not shown on the page. How can I test the
> variable first? I'm thinking of something along the lines of:
>
> if ( isDefined ( "#createNewAccount") ) {   // continue... }
>
> Many thanks for any help!
>



-- 
Isaak Malik
Web Developer

Reply via email to