Welcome Guest [Log In] [Register]
Search Members Calendar | Rules ZB Code Index IF Code Index
ZBCode
  • Navigation
  • ZBCode
  • Coding Support
  • Code University
  • [ZB] Jquery help - applying CSS to reportCP link
Hey, welcome to ZBCode, the premier coding forum for ZB. Here you fill find some of the best Invisionfree and Zetaboards Codes on the network! Unfortunately, you're sorta hovering around in guest mode at the moment; why not join in on the fun? Register an account and you can start accessing the wealth of resources we have available here. Enjoy your stay at ZBCode, and remember to tell all your friends about us; the more members, the more codes available. ;)

Interested in joining? Click here.


If you are already a member of ZBCode, feel free to login right here:

Username:   Password:
Locked Topic
[ZB] Jquery help - applying CSS to reportCP link
Tweet Topic Started: Apr 7 2009, 06:07 AM (212 Views)
gladstone Apr 7 2009, 06:07 AM Post #1


Posts:
31
Group:
Member
Member
#922
Joined:
Sep 12, 2008
Coding language
HTML/CSS
So I have this:

$("#menu_rcp a:contains('1')").css({ "background-color":"#BF0000" });

Whenever there is a report, the background of the 'menu_rcp a' class turns a shade of red. What I don't know how to do is to write the code so that with any number of reports, one onwards, the background colour changes.

Thanks ^^
Offline Profile Goto Top
 
Reid Apr 8 2009, 09:09 AM Post #2
Member Avatar
What? The land of the free? Whoever told you that was your enemy.

Posts:
1,790
Group:
Distinguished Coder
Member
#148
Joined:
Jul 20, 2008
Ah, good old regular expressions rear their ugly head again.

I'm not exactly a jQuery master - I know enough to make my code shorter but I don't work with it that often - so this is what I would do

Code:
 

$("#menu_rcp a").each(function(){
if (this.match(/[1-9]/gi)) this.style.backgroundColor="#BF0000";
});


I feel that should work, but I make no guarantees. I just woke up after all.. the times I normally poke my head around coding forums.. a habit I should change, I think. :P

Also, it dawned on me while I looked at the code that there is only one ID of menu_rcp so I shouldn't be using .each() - I'm not sure of an alternative, however, as again I only dabble lightly in jQuery.

Does anyone have one? Lol.
The Resource Board
Offline Profile Goto Top
 
gladstone Apr 9 2009, 12:22 PM Post #3


Posts:
31
Group:
Member
Member
#922
Joined:
Sep 12, 2008
Coding language
HTML/CSS
doesn't appear to workies :(
Offline Profile Goto Top
 
rockon1824 Apr 9 2009, 02:56 PM Post #4
Member Avatar
I never know what to put for my member title. =(

Posts:
186
Group:
Member
Member
#424
Joined:
Aug 2, 2008
Coding language
HTML/CSS
Give this a shot:
Code:
 
var rcpn = $("#menu_rcp a strong small").text();
if(rcpn > 0){
$("#menu_rcp a").css("background-color","#bf0000");
}
Posted Image
Offline Profile Goto Top
 
gladstone Apr 9 2009, 05:40 PM Post #5


Posts:
31
Group:
Member
Member
#922
Joined:
Sep 12, 2008
Coding language
HTML/CSS
Thanks dude, that works ^^
Offline Profile Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
« Previous Topic · Code University · Next Topic »
Locked Topic

Track Topic · E-mail Topic Time: 7:48 PM Jul 10
Hosted for free by ZetaBoards · Privacy Policy