select the divs whose class contain "myDivs", do an each() and within the function check the numeric suffix of the class
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script>
$(function(){
$("div[class*=myDivs]").each(function(){
var id=($(this).attr('class')).match(/(\d+)$/)[0];
if( 7 <= id && id <=12)
{
doSomething( id, this.className );
}
});
});
function doSomething(id, cls){
alert( 'class="' + cls + '" with numeric id=' + id);
}
</script>
</head>
<body>
<div class="myDivs6">6</div>
<div class="myDivs7">7</div>
<div class="myDivs8">8</div>
<div class="myDivs9">9</div>
<div class="myDivs10">10</div>
<div class="myDivs11">11</div>
<div class="myDivs12">12</div>
<div class="myDivs13">13</div>
</body>
</html>
Reputation Points: 116
Solved Threads: 243
Veteran Poster
Offline 1,123 posts
since Dec 2007