Hi,
I have this code:
var alldrags = $$('#dragGame' + gameCount '.dragMe');
But it's causing an error somehow. I''m trying to say select all div's
with dragMe class inside the dragGame (plus an incrementing number)
div but this is throwing an error saying my function is not defined.
I've also tried assigning the dragGame selector to a variable....like
so:
var dragGame = '#dragGame' + gameCount;
and then doing the selector like so:
var alldrags = $$(dragGame '.dragMe');
Both ways are throwing an error saying my function isn't defined.
Any ideas?
Thanks
on 2008-06-27 11:20
on 2008-06-27 12:20
You just missed the plus (+) sign.
It should be like this:
var alldrags = $$('#dragGame' + gameCount + '.dragMe');
and
var alldrags = $$(dragGame + '.dragMe');
:)
on 2008-06-27 12:32
Hi,
Thanks for the reply. I don't think that's it....that'll give me
#dragGame1.dragMe as the + has concatenated the whole thing. I have
tried it but it doesn't work. From looking at the api docs theres an
example like this...:
$$('#contents a[rel]');
// -> all links inside the element of ID "contents" with a rel
attribute
So i'm assuming that using a space is what needs to be done to select
everything in the dragGame1 div taht has a class of dragMe.
on 2008-06-27 13:03
Then, it should be like this:
var alldrags = $$('#dragGame' + gameCount + ' .dragMe');
or more specific
var alldrags = $$('#dragGame' + gameCount + ' div.dragMe');
on 2008-06-27 14:54
Right. In CSS a space means "any descendant of."
So "div.someClass" means all divs with a class of someClass, while "div
.someClass" means any element with a class of someClass that is a
descendant
of any div.
-Fred
On Fri, Jun 27, 2008 at 5:31 AM, elduderino
<jamesfiltness@googlemail.com>
wrote:
> attribute
--
Science answers questions; philosophy questions answers.
on 2008-06-27 14:58
You want a selector of:
#dragGame<n> <space> .dragMe
Where n is the value of gameCount?
That's $$('#dragGame' + gameCount + ' .dragMe'). Note the space.
You were on the right track, but in JS you always need an explicit + to
do
string concatenation.
-Fred
On Fri, Jun 27, 2008 at 4:20 AM, elduderino
<jamesfiltness@googlemail.com>
wrote:
>
> Hi,
>
> I have this code:
>
> var alldrags = $$('#dragGame' + gameCount '.dragMe');
--
Science answers questions; philosophy questions answers.