Thanks for this response.

Unfortunately, I am left with the problem that Internet Explorer
doesn't seem to like the syntax $("#createNewAccount").

It works fine in firefox - any suggestions please?

On Jun 19, 10:33 pm, Hamish Campbell <[EMAIL PROTECTED]> wrote:
> Hi there.
>
> Best (or fastest) way to find out if something is in the DOM is to
> check:
>
> if ( $("#createNewAccount").length )
>
> If .length is greater than 0 it will exist.
>
> So your script can read:
>
> $(document).ready(function() {
>     if ( $('#createNewAccount:checked').length || !$
> ('#createNewAccount').length ){
>         $('div.showHideAccountDetails').show();
>     }else{
>         jQuery('div.showHideAccountDetails').hide();
>     }
>
> });
>
> Ie, if it finds (  '#createNewAccount' that is checked ) OR ( it can't
> find any '#createNewAccount' ) { show the div } otherwise { hide it }
>
> Hope this helps!
>
> Hamish
>
> On Jun 20, 2:10 am, "[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!

Reply via email to