[jQuery] UPDATED - possibility complicated color codingquestion, now with example...
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2900.2912" name=GENERATOR></HEAD>
<BODY>
<DIV><SPAN class=781200721-07082006><FONT face=Arial color=#0000ff
size=2>Hmmm...learning something new. I'll give this a try and see what I get.
At this point I foresee only 12 possible colors for the map so hardcoding them
into the original $() object wouldn't be that hard. But for other projects, what
if there were more possibilities? Could jQuery do some sort of matching like
so:</FONT></SPAN></DIV>
<DIV><SPAN class=781200721-07082006><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=781200721-07082006><FONT face=Arial color=#0000ff
size=2>$('.p~~') where ~~ might match other options where the class name started
with "p"?</FONT></SPAN></DIV>
<P><FONT size=2><!----------------//------<BR>andy matthews<BR>web
developer<BR>certified advanced coldfusion programmer<BR>ICGLink,
Inc.<BR>andy@icglink.com<BR>615.370.1530
x737<BR>--------------//---------></FONT> </P>
<BLOCKQUOTE>
<DIV class=OutlookMessageHeader dir=ltr align=left><FONT face=Tahoma
size=2>-----Original Message-----<BR><B>From:</B> discuss-bounces@jquery.com
[mailto:discuss-bounces@jquery.com]<B>On Behalf Of </B>Jonathan
Sharp<BR><B>Sent:</B> Monday, August 07, 2006 3:52 PM<BR><B>To:</B> jQuery
Discussion.<BR><B>Subject:</B> Re: [jQuery] UPDATED - possibility complicated
color codingquestion, now with example...<BR><BR></FONT></DIV>Your example
didn't work for me. A few minor changes though: <BR><BR><PRE id=line1>function colorPop() {<BR> $('.p25').addClass('pLev25');<BR>}<BR>function colorTotal() {<BR> $('.p25').addClass('pLev25');<BR>}</PRE><BR>Your
class is p25 not pop25... <BR><BR>You can grab all of the classes like:
<BR>$('.p25, .p50, .p75, .p100').each(function(){<BR> var t
= $(this);<BR> if (t.is('.p25'))
{<BR>
t.addClass('pLev25');<BR> } else if (t.is('.p50'))
{<BR>
t.addClass('pLev50');<BR> }<BR>});<BR><BR>Hope this helps...
(it's best to store a reference t since you'll be calling the jquery object
multiple times)<BR><BR>-js<BR><BR><BR><BR>
<DIV><SPAN class=gmail_quote>On 8/7/06, <B class=gmail_sendername>Andy
Matthews</B> <<A href="mailto:andy@icglink.com">andy@icglink.com</A>>
wrote:</SPAN>
<BLOCKQUOTE class=gmail_quote
style="PADDING-LEFT: 1ex; MARGIN: 0pt 0pt 0pt 0.8ex; BORDER-LEFT: rgb(204,204,204) 1px solid">Okay...<BR><BR>I
started a test page so that I can see if I can get this working.<BR><A
href="http://commadelimited.com/travian/maptest.html">http://commadelimited.com/travian/maptest.html</A><BR><BR>This
moves on the suggestion that applying multiple fake classes can be used
<BR>as placeholders for the real classes.<BR><BR>So if you load up that
page, you'll see some fake data. What I want to<BR>happen is when someone
clicks the color by population button, jQuery loops<BR>through all divs
searching for any class which begins with a p+number (right <BR>now:
25,50,75,100), then replaces that with pLev + number.<BR><BR>The same thing
should happen with the color by total village button. Based<BR>on someone
else's sugestion, it looks like $().each() would be the method I <BR>want,
but how can I, in one line, grab all possibilities of
p+number?<BR><BR>Anyone have ideas on
this?<BR><BR><BR><!----------------//------<BR>andy matthews<BR>web
developer<BR>certified advanced coldfusion programmer <BR>ICGLink,
Inc.<BR><A
href="mailto:andy@icglink.com">andy@icglink.com</A><BR>615.370.1530
x737<BR>--------------//---------><BR><BR><BR>_______________________________________________<BR>jQuery
mailing list<BR><A
href="mailto:discuss@jquery.com">discuss@jquery.com</A><BR><A
href="http://jquery.com/discuss/">http://jquery.com/discuss/</A><BR></BLOCKQUOTE></DIV><BR></BLOCKQUOTE></BODY></HTML>
_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/