Tom Knowlton
asked on
Please help with changing child div class
In the following html:
I need to change the styling for the div with class "TopCartImageAlign" to "SpecialTopCartCellAlign"
<td class="TopCartCellAlign">
<div class="TopCartImageAlign"> <a id="ctl00_TopCart2_hlViewC art" href="CartDetails.aspx"><i mg src="App_Themes/utenn/Imag es/cart.gi f" alt="view cart" style="border-width:0px;" /></a></div>
</td>
changes to:
<td class="SpecialTopCartCellA lign">
<div class=""><a id="ctl00_TopCart2_hlViewC art" href="CartDetails.aspx"><i mg src="App_Themes/utenn/Imag es/cart.gi f" alt="view cart" style="border-width:0px;" /></a></div>
</td>
Must "td" have an id asigned for this to work?
There is also the following restriction:
-the div must be a descendant (child or grandchild) of a div with id containing the words "TopCart2"
<div id="ctl00_TopCart2_upCart">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="TopCartCellAlign">
<div class="TopCartImageAlign"><a id="ctl00_TopCart2_hlViewCart" href="CartDetails.aspx"><img src="App_Themes/utenn/Images/cart.gif" alt="view cart" style="border-width:0px;" /></a></div>
</td>
<td class="TopCartCellAlign">
<span id="ctl00_TopCart2_lblTotalItems" class="TopCartItemsCountNumberDisplayed">0</span>
<span id="ctl00_TopCart2_Label1" class="TopCartItemsCountText">Item(s) totaling</span>
<span id="ctl00_TopCart2_lblTotalAmount" class="TopCartTotalAmount">$0.00</span>
</td>
</tr>
</table>
</div>
I need to change the styling for the div with class "TopCartImageAlign" to "SpecialTopCartCellAlign"
<td class="TopCartCellAlign">
<div class="TopCartImageAlign">
</td>
changes to:
<td class="SpecialTopCartCellA
<div class=""><a id="ctl00_TopCart2_hlViewC
</td>
Must "td" have an id asigned for this to work?
There is also the following restriction:
-the div must be a descendant (child or grandchild) of a div with id containing the words "TopCart2"
or (you change name of the class in your question, first time TopCartImageAlign and after : TopCartCellAlign) :
$(".TopCartCellAlign").rem oveClass(" TopCartCel lAlign").a ddClass("S pecialTopC artCellAli gn");
$(".TopCartCellAlign").rem
ASKER
TopCartImageAlign is used in other places and I don't want it changed in those places....just where the class "TopCartImageAlign" has a parent div with an id containing "TopCart2".
So changing the assigned div for say "TopCart1" would not be desired.
:)
So changing the assigned div for say "TopCart1" would not be desired.
:)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I noticed you use two params in the first part:
$(".TopCartImageAlign", "div[id*='TopCart2']").
Can you tell me more about what each param is for? I mean, I think I know...but can you talk about a it some?
$(".TopCartImageAlign", "div[id*='TopCart2']").
Can you tell me more about what each param is for? I mean, I think I know...but can you talk about a it some?
ASKER
I was thinking about trying this:
//$('div[id*="TopCart2"] > ') blah blah
Would this be valid as well?
//$('div[id*="TopCart2"] > ') blah blah
Would this be valid as well?
could you confirm it work first? thanks
ASKER
Works just great!!
ASKER
thx
$(".TopCartImageAlign", "div[id*='TopCart2']") similar to :
$("div[id*='TopCart2']").f ind(".TopC artImageAl ign")
this return an array of jQuery object
removeClass and addClass is applied to all the jQuery objects of this array.
Check this page : http://api.jquery.com/jQuery/
jQuery( selector, [ context ] )
my favorite page : http://api.jquery.com/category/selectors/
$("div[id*='TopCart2']").f
this return an array of jQuery object
removeClass and addClass is applied to all the jQuery objects of this array.
Check this page : http://api.jquery.com/jQuery/
jQuery( selector, [ context ] )
my favorite page : http://api.jquery.com/category/selectors/
ASKER
LK:
Thank you so much for this information!
I welcome any other sites you use on a regular basis for jQuery type questions, if you want to share additional sites!!
I own the following books by O'Reilly which are great:
http://www.amazon.com/jQuery-Cookbook-Solutions-Examples-Developers/dp/0596159773
and
http://www.amazon.com/jQuery-Pocket-Reference-David-Flanagan/dp/1449397220/ref=sr_1_1?s=books&ie=UTF8&qid=1315845020&sr=1-1
but sometimes you are still a lot faster. :)
Thank you so much for this information!
I welcome any other sites you use on a regular basis for jQuery type questions, if you want to share additional sites!!
I own the following books by O'Reilly which are great:
http://www.amazon.com/jQuery-Cookbook-Solutions-Examples-Developers/dp/0596159773
and
http://www.amazon.com/jQuery-Pocket-Reference-David-Flanagan/dp/1449397220/ref=sr_1_1?s=books&ie=UTF8&qid=1315845020&sr=1-1
but sometimes you are still a lot faster. :)
yeah, I've some O'Reilly books, I love them too (Java, Oracle, TCP/IP, ...)
I found all the infos I need on the jQuery site itselft or for UI : http://jqueryui.com/
I found all the infos I need on the jQuery site itselft or for UI : http://jqueryui.com/
$(".TopCartImageAlign").re