Monday, 15 August 2011

javascript - Change DIV width that is before another DIV -


I have this structure with dynamic DIV and everyone has the same class, because all are automatically created .

The problem here is that, before the other DIVs of the second class, the last of them, I would like to keep my style as width: 100% instead of width: 50 as all other prescribed by CSS %.

Here's a sample:

  & lt; Div class = "awp_box awp_box_inner" & gt; & Lt; / Div & gt; & Lt; Div class = "awp_box awp_box_inner" & gt; & Lt; / Div & gt; & Lt; Div class = "awp_box awp_box_inner" & gt; & Lt; / Div & gt; & Lt; Div class = "awp_stock_container awp_sct" style = "max-width: 400px! Important;" & Gt; & Lt; / Div & gt;  

So I want to change only that third DIV, which is sometimes the first and only, the second is second, the second time the fourth, etc. ...

I am generally good with CSS, but at this time I have a hard time finding one solution for one.

Can someone guide me in the right direction, so how can I do this work?

Depending on the comments, the following script may give you what you need.

  $ (document) .ready (function () {$ ('. Awp_sct')) prev (). AddClass ('full');});  

This will add a class to the previous element of .pap_sct.


No comments:

Post a Comment