Per Richard's comment, if you know the tag names of the elements that will match the class (like div, p), you can do the following:
$("div,p").filter(function(){ var classes = $(this).attr("className").split(" "); var found = false; for (var i = 0; i < classes.length; i++){ if ( classes[i].substr(0,4) == "rate" ){ found = true; break; } } return found; }); This creates an array of all the classes on each matched element and loops over them, testing if the first four characters are "rate", and removing the elements that fail the test from the wrapped set. It wouldn't be hard to create a more generic jQuery plugin from this, maybe one that accepts a parameter for the string to test. Anyone, feel free to correct my code if there is an error. Bradley~ On Nov 11, 6:29 pm, "Richard D. Worth" <[EMAIL PROTECTED]> wrote: > Don't forget that elements can have more than one class (each separated by a > space), so such a test will only pass if it's the first in the list. > > - Richard > > On Tue, Nov 11, 2008 at 6:22 PM, Rik Lomas <[EMAIL PROTECTED]> wrote: > > > To get a class that begins with 'rate', you can do > > $('*[className^="rate"]') > > > Note that the attribute is className, not class > > > $('*[className^="rate"]').each(function () { > > alert( $(this).attr('className').split('rate')[1] ); > > }); > > > 2008/11/11 debussy007 <[EMAIL PROTECTED]>: > > > > Hi, > > > > How is it possible to get the class that starts with 'rate' of an element > > ? > > > > the class could be rate1, rate5, rateXYZ. > > > I don't know what follows the substring 'rate'. > > > I need to get the number that follows rate. > > > > Thank you for any help ! > > > -- > > > View this message in context: > >http://www.nabble.com/get-the-class-that-starts-with-...-tp20450061s2... > > > Sent from the jQuery General Discussion mailing list archive at > > Nabble.com. > > > -- > > Rik Lomas > >http://rikrikrik.com