Thanks George,

Great respons gives a better understanding of jquery but unfortunately
it didn't help on my IE and Safari problem.
modified the code to reflect your answer:

$(function () {

                                $('input[name][id$=div]').change(function(){
                                        
$('#'+this.name).css('background-color', this.value);
                                });
                                $('input[name][id$=text]').change(function(){
                                        $('#'+this.name).css('color', 
this.value);
                                });
                });


Firefox make this work fine but IE and Safari are still unresponsive.

Hollow

On Jan 17, 9:33 am, George <[EMAIL PROTECTED]> wrote:
> There may be some confusion over the use of commas in your jQuery
> selectors. You can use commas *in* the selector string when you need
> more than one selector but you cannot put commes between jQuery calls
> (that would not be valid javascript).
>
> It should work if you remove the two occurrences of $
> ('input[name]'),
>
> If you do need to test for the presence of the name attribute then you
> could try
>
>     $('input[name][id$=div]')   instead
>
> Cheers,
> George
>
> PS: You can also reduce  $(document).ready(function(){...      to
> just    $(function(){...
>
> On Jan 16, 8:52 pm, hollow <[EMAIL PROTECTED]> wrote:
>
> > The script presented  here works like a charm in firefox 2.
> > But it doens't do anything on IE or safari.
> > What it is supposed to do is take the name of a input field then the
> > id if it is text, div.
> > then change the color depending on the id of the input field
> > if it is text then change the text color.
> > if it is div change the bgcolor of the div.
> > $(document).ready(function () {
> >                                 $('input[name]'),$('input[id
> > $=div]').change(function(){
> >                                         $
> > ('#'+this.name).css('background-color', this.value);
> >                                 });
> >                                 $('input[name]'),$('input[id
> > $=text]').change(function(){
> >                                         $('#'+this.name).css('color',
> > this.value);
> >                                 });
> >                 });
> > For some reason it doesn't make the changes in corresponding divs in
> > IE or safari.
> > Help would be much appreciated.
> > Hollow

Reply via email to