vostro Posted November 30, 2011 Report Share Posted November 30, 2011 Vai ir iespējams selector klasei norādīt tā, lai pēc klases rating jebkurš skaitlis darbotos kods? $(".rating").each(function(){ if( parseInt($(this).html()) < 0 ) { $(this).addClass("redStar"); } else { $(this).addClass("greenStar"); } Piemērs : <span class="rating1"> <span class="rating2"> <span class="rating32"> <span class="rating50"> Mēģināju: $(".rating*") $(".rating"+'*') Nestrādā! Quote Link to comment Share on other sites More sharing options...
xPtv45z Posted November 30, 2011 Report Share Posted November 30, 2011 (edited) http://api.jquery.com/attribute-starts-with-selector/ $('span[class^="rating"]') Edited November 30, 2011 by xPtv45z Quote Link to comment Share on other sites More sharing options...
vostro Posted November 30, 2011 Author Report Share Posted November 30, 2011 (edited) xPtv45z paldies! Edited November 30, 2011 by vostro Quote Link to comment Share on other sites More sharing options...
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.