javascript - jQuery classname with any number between -


i'm stuck 4 hours searching , changing small portion of code able match classname.

my page code filled classnames "option-274-82"

my jquery function @ point try match div show , must :

"option-" + anynumber + "-" + id

jquery('.option-274-'+id+' dd').fadein(); 

the "274" it's control value , must regex expression, understand.

many reading question.

using filter(), can return div matching regex ^option-\d+-\d+$.

$('div')      .filter(function() {          return this.classname.match(/^option-\d+-\d+$/);      })      .fadein(2000);
.option-1-2, .option-1-a {    width: 100px;    height: 100px;    background: #555;    display:none;  }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>  <div class="option-1-2"></div>  <div class="option-1-a"></div>


Comments

Popular posts from this blog

sql server - Cannot query correctly (MSSQL - PHP - JSON) -

php - trouble displaying mysqli database results in correct order -

C++ Linked List -