inherit
130228
0
Jul 11, 2024 19:19:59 GMT -8
Charles Stover
1,731
August 2008
gamechief
|
Post by Charles Stover on Aug 10, 2010 20:09:51 GMT -8
Let's say the default link color in #id is #000000. I'm trying to do:
$("#id a").css("color", "#ffffff"); The <a>s in #id change every 5 seconds as part of a news feed (old ones erased, new ones created). The <a>s that replace the old white ones will be black (the default color as defined by the stylesheet). How do I change the CSS of future #id a tags? I tried:
$("#id a").live("load ready", function() { $(this).css("color", "#ffffff"); } ); But to no avail. Is there a function for changing CSS values that works similar to live()?
|
|
inherit
100824
0
May 13, 2012 5:37:49 GMT -8
Michael
14,585
March 2007
wrighty
|
Post by Michael on Aug 11, 2010 5:02:45 GMT -8
You have a function to change the <a>s, I'm guessing, so when you append the new <a> why not change it's color then?
Got a larger section of the code? Have you tried using:
$('#id a').ready(function(){ $(this).css('color', '#FFF'); });
instead of live?
Or you could set a timeout to change the colour of the <a> tag that is within the news feed thing =]
|
|
inherit
130228
0
Jul 11, 2024 19:19:59 GMT -8
Charles Stover
1,731
August 2008
gamechief
|
Post by Charles Stover on Aug 11, 2010 8:48:37 GMT -8
.ready() only works for elements that already exist. .live() will .bind() an action when the element exists. As shown in the post, I already tried live("ready") and live("load"). Neither work.
And changing the link color after it exists only makes it more complicated. Simply put, that's the reason .live() exists - so you don't have to add an event function every time you create an element. It's much simpler to set it once and forget about it, so running the command for a color change only has to happen once instead of every time an element is created.
|
|