0

i have this situation:

here start foor loop ...

$("#sez:last").append("<div id=\"sezDati\" class=\"counter_"+d+"\">"+name+"</div>");         if ( d  ==  6  ){ $("#sez:last").find(".counter_6").after().wrap("</div><div id=\"sezDati\">");
}
d++

After 6 div #sezDati i need to append first a close tag then reopen a sezDati div... Any help??

thanks

2
  • You selector seems to be wrong. What you are trying to do is that selecting the last element from elements that have ids sez. Having more than 1 element with the same id is invalid.
    – rahul
    Nov 11, 2010 at 9:16
  • Ok but it not work also if i use class instead id...
    – Ste
    Nov 11, 2010 at 9:26

1 Answer 1

0

You really shouldn't be using the same id for more than one element. Use your counter to generate the dynamic ids and use those instead. Also why are you using .after().wrap() in this case? Surely what you need is just an .after().

Something like:

$("#sez:last").append("<div id=\"sezDati_"+d+"\" class=\"sezDati\">"+name+"</div>");
if ( d  ==  6  ){ 
   $("#sez:last").find(".sezDati_6").after("</div><div id=\"sezDati\">");
}
d++
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.