[jQuery] Re: JQuery variables

2008-06-20 Thread Isaak Malik
The use of jQuery's $("#createNewAccount"). is cross-browser so you
shouldn't worry about IE.

On Fri, Jun 20, 2008 at 11:42 AM, Neilz <[EMAIL PROTECTED]> wrote:

>
> 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!
>



-- 
Isaak Malik
Web Developer


[jQuery] Re: JQuery variables

2008-06-20 Thread Neilz

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!


[jQuery] Re: JQuery variables

2008-06-19 Thread Isaak Malik
#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


[jQuery] Re: JQuery variables

2008-06-19 Thread Hamish Campbell

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!