2

I am generating some html tables within a loop with dynamic class names. These classes look like:

<tr class="method_11">
<tr class="method_12">
<tr class="method_13">

Is there a way to select all of the above classes by only using their common parts

$('.method_options_1'+' ')?

KP.
  • 12,740
  • 3
  • 39
  • 60
TTT
  • 4,114
  • 12
  • 69
  • 120

3 Answers3

3
$('tr[class^="method_"]')

This selects elements where attribute "class" starts with "method_", which matches your criteria.

KP.
  • 12,740
  • 3
  • 39
  • 60
3

start with:

$("tr[class^='method_']")

http://api.jquery.com/attribute-starts-with-selector/

CD..
  • 68,981
  • 24
  • 147
  • 156
0

Are you looking for something like css wilcards?

I guess jQuery closely follows css selectors

wildcard * in CSS for classes

Community
  • 1
  • 1
sabithpocker
  • 14,744
  • 1
  • 38
  • 71