Link to home
Start Free TrialLog in
Avatar of Tom Knowlton
Tom KnowltonFlag for United States of America

asked on

jquery getting overwritten by CSS?

I think my jQuery CSS changes are getting overwritten by the THEME css for the page that gets applied.

How can I correct this?

I either want to run the jquery AFTER the css gets applied

or

set up a trigger event on the css getting changed.  If the class changes to this then do something.

        $('span[id*="TopCart2_lblTotalItems"]').css("color", "#532B8F");
        $('span[id*="TopCart2_Label1"]').css("color", "#532B8F");
        $('span[id*="TopCart2_lblTotalAmount"]').css("color", "#532B8F");

In essence, if the color changes to anything OTHER THAN #532B8F then I want to change the color BACK to #532B8F



ASKER CERTIFIED SOLUTION
Avatar of leakim971
leakim971
Flag of Guadeloupe image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Tom Knowlton

ASKER

They were all equal to 0.
Are your waiting the total loading of the page with the following for example :

$(document).ready(function() {

alert( $('span[id*="TopCart2_lblTotalItems"]').length ); // should be greater than zero
alert( $('span[id*="TopCart2_Label1"]') ); // should be greater than zero
alert( $('span[id*="TopCart2_lblTotalAmount"]') ); // should be greater than zero
$('span[id*="TopCart2_lblTotalItems"]').css("color", "#532B8F");
$('span[id*="TopCart2_Label1"]').css("color", "#532B8F");
$('span[id*="TopCart2_lblTotalAmount"]').css("color", "#532B8F");


})
>>>>Are your waiting the total loading of the page with the following for example :

$(document).ready(function() {

--------------------------------------------------


Yes
Ok, so double check the ID of the SPAN

If you can use Control.ClientID : http://msdn.microsoft.com/en-us/library/system.web.ui.control.clientid.aspx

http://dotnetslackers.com/ASP_NET/re-113573_The_difference_between_ID_ClientID_and_UniqueID.aspx

$('span[id*="TopCart2_lblTotalItems"]')

mean something like : <span id="smlfksmfsflksflmsfmskTopCart2_lblTotalItemsfksflfmkfmskj">
It seems to happen on the button click...

see screencast knowlton-499411.flv
At about time index :48 I click on the "Add to Cart" button and the cart styling goes all crappy.
If I refresh the page AFTER the styling goes away....the styling gets applied again.

It's something with the button click.
with << code behind >>
Now I can't get it to do it anymore....

:::: frustrating :::::


I guess it was a temporary glitchy thing....oh well.

Thanks for the time and effort...if it happens again I'll come back to try a few of the other suggestions...
thx