And, to clarify further, the selector for elements with both 'btn' &
'px' classes[1] is '.btn.px'. Note that there's a dot before both
class names. There's also no space--'.btn .px' would select for an
element with classname 'px' inside of another with classname 'btn'.
Remember that jQuery's classname and ID selectors mirror those found
in your stylesheets, not your element attributes.

[1] Of course, either '.btn' or '.px' would work, also but '.btn.px'
is what's required to narrow it down to elements with both.

On Mon, Feb 2, 2009 at 12:21 AM, Michael Geary <m...@mg.to> wrote:
>
> Ricardo and Brian both explained that .is('.btn px') tests for a <px>
> element inside an element with class="btn" - not an element with class="btn
> px".
>
> You don't have a <px> element, do you? If not, then your code that sets the
> background color is never being executed.
>
> Try putting an alert() or a console.log() in that code and see if it gets
> there.
>
> To illustrate further, try these tests in Firebug:
>
> $('<div class="btn px"></div>').is('.btn px')
>
> returns false.
>
> $('<div class="btn"><px></px></div>').children().is('.btn px')
>
> returns true.
>
> -Mike
>
>> From: thertze...@gmail.com
>>
>> Right but you can have to classes defined to one element, and
>> thats what is being done here. The statement does validate
>> nonetheless, but rather why this.css doesn't correctly
>> reassign the background is what i"m unsure of.
>>
>> On Feb 1, 12:20 pm, brian <bally.z...@gmail.com> wrote:
>> > On Sun, Feb 1, 2009 at 12:09 PM, thertze...@gmail.com
>> >
>> > <thertze...@gmail.com> wrote:
>> >
>> > > what?
>> >
>> > > That statement checks to see if the element clicked has
>> the class of
>> > > .btn px, I dont know what your saying, the statement
>> there does work
>> > > correctly, its "\$(this).css({ backgroundColor:color });
>> " that isnt
>> > > modifying the css, thats where my problems are.
>> >
>> > Class names cannot have spaces. Ricardo is correct; the selector
>> > you're using is for a "px" element inside of another with classname
>> > 'btn'.
>> >
>> > > It's being ran from perl, so when perl is parsing the print
>> > > statement, it thinks $~whatever is a perl variable. Which is
>> > > strange, because normally use strict; will bark at you,
>> but instead
>> > > perl finds a way to find out what $~whatever is. Its
>> kinda strange,
>> > > so I have to escape them server side, but client side
>> they come out
>> > > as normal $
>> >
>> > Sure it requires escaping for Perl. But, effectively,
>> you're posting a
>> > Perl print statement, not JS.  Post the actual, real lines
>> of code, as
>> > it will be when it meets the interpreter. Any format it's
>> in before it
>> > reaches the browser is unimportant and just getting in the
>> way. Just
>> > "view source" and copy that.
>> >
>> > Next, people will be posting their gzipped scripts to be
>> debugged. ;-)
>>
>
>

Reply via email to