Can Jquery alternate color of text,
Note, I cannot get into the html to add an id. Also, note, I had already found the jquery zebra strips tutorial but can`t get it to work for this si开发者_StackOverflowtuation.
I have a link like this ( I have changed the domain name).
<li class="tab tab-home current"><a href="http://yourmamaisyourmama.com">submitpics@yourmamaisyourmama.com</a></li>
NOTE the URL will always be the same, because it is the homelink on a webpage.
To make the email address easier to read, I would like to have the words alternate color between red and blue, with the submitpics@ in black, all on a white background.
submitpics@ = black
Your=blue
Mama=Red
Is=blue
Your=blue
I know Jquery can do zebra stripes for rows, but this is different and I haven`t been able to figure it out.
These are the default styles that currently determine the CSS
.menu .current-menu-item a:hover {
color: red;
background: #fff
}
Can anyone give me some guidance?
EDIT 2
So you can't edit the HTML. Ok. Do this:
$(function(){
$('.tab.tab-home.current a').html('submitpics@
<span class="class1">your</span><span class="class2">mama</span>... etc');
});
and then update your CSS accordingly. Basically you're just replacing the content with whatever you want.
EDIT
So it sounds like you're going to know the URL in advance. That's great. If you want the address to change colors, you don't need jQuery. Just wrap everything in span
s:
<a href="whatever.com">submitpics@
<span class="class1">your</span><span class="class2">mama</span>... etc
there's really no way to do this unless you know what the URL is going to be ahead of time or your URLs are Pascal-cased (or you have an engine that can read and understand English). There needs to be something that you can split on, and a generic email address does not have that, except for the @
and the .
before the TLD. The best you could do is make the string before the @ symbol one color, the domain another, and the TLD yet another without knowing what the URL is going to be ahead of time.
That said, if you know what the URL is going to be ahead of time or you have a specific string you're looking for, then you can do all sorts of fancy things. But it sounds like you won't, so, yeah.
Sorry brah
精彩评论