mbitenieks Posted February 22, 2012 Report Share Posted February 22, 2012 Meerkjis ir pievienot <div></div> arpus <ul> ja ir vairaak par vienu <li></li> Bet ar sho nesanaak: $j("ul").find("li").eq(1).addClass("vairak-par-vienu"); $j("li.vairak-par-vienu").parent().parent().append('<div></div>'); Paldies! Quote Link to comment Share on other sites More sharing options...
0 codez Posted February 22, 2012 Report Share Posted February 22, 2012 http://jsfiddle.net/Gy3MC/ $('ul').each(function(){ if($(this).children().length>1){ $(this).after($('<div>hello</div>')); } }); Quote Link to comment Share on other sites More sharing options...
0 mbitenieks Posted February 22, 2012 Author Report Share Posted February 22, 2012 (edited) Paldies par tik aatru atbildi! Google Chrome izmet Uncaught SyntaxError: Unexpected token ILLEGAL Divaini jo taa nevajadzeetu buut. bet tomeer palaizhot lapaa. nestradaa! $j(document).ready(function(){ $j('#circle-slider').each(function(){ if($j(this).children().length>1){ $j(this).after($j('<div class="single-blog-nav"> <div id="next2"></div> <div id="prev2"></div> <div class="clear"></div> </div>')); } }); }); Paldies! Edited February 22, 2012 by mbitenieks Quote Link to comment Share on other sites More sharing options...
0 codez Posted February 22, 2012 Report Share Posted February 22, 2012 Google Chrome izmet Uncaught SyntaxError: Unexpected token ILLEGAL http://stackoverflow.com/questions/4404526/unexpected-token-illegal-in-webkit Quote Link to comment Share on other sites More sharing options...
0 mbitenieks Posted February 22, 2012 Author Report Share Posted February 22, 2012 Iztesteeju jau visu ko tur aprakstiija. bet tikuntaa neliidzeeja. Varbuut ir kaada savaadaaka iespeeja? cits funkcijas veids? Paldies! Quote Link to comment Share on other sites More sharing options...
0 mbitenieks Posted February 22, 2012 Author Report Share Posted February 22, 2012 Sanaaca $j(document).ready(function(){ if($j('#circle-slider').children().length>1){ $j('#circle-slider').after($j('<div class="single-blog-nav"> <div id="next2"></div> <div id="prev2"></div> <div class="clear"></div> </div>')); } }); Paldies! Quote Link to comment Share on other sites More sharing options...
0 codez Posted February 22, 2012 Report Share Posted February 22, 2012 Problēma nav kodā, bet tajā, ka esi ielicis kodā kādu neatļautu simbolu, vai nu kopējot, vai kā savādāk, jo jsfiddlē kods darbojas. Iesaku izmantot kādu IDE (piem. Netbeans) ar sintakses pārbaudītāju, tāds uzreiz uzrādīs, kurā vietā ir neatļauts simbols. Quote Link to comment Share on other sites More sharing options...
0 indoom Posted February 22, 2012 Report Share Posted February 22, 2012 Intereses pēc paskatījos, vai nav kāds cits variants $('ul').has('li + li').after('<div>hello</div>'); lēnāks, bet ātrāks par each() tikai, ja ir vismaz 10 vai vairāk ul lapā $('ul').has('li:not(:only-child)').after('<div>hello</div>'); vispār lēns Quote Link to comment Share on other sites More sharing options...
Question
mbitenieks
Meerkjis ir pievienot <div></div> arpus <ul> ja ir vairaak par vienu <li></li>
Bet ar sho nesanaak:
$j("ul").find("li").eq(1).addClass("vairak-par-vienu");
$j("li.vairak-par-vienu").parent().parent().append('<div></div>');
Paldies!
Link to comment
Share on other sites
7 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.