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.
  • 13,218
  • 3
  • 40
  • 60
TTT
  • 4,354
  • 13
  • 73
  • 123

3 Answers3

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

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

KP.
  • 13,218
  • 3
  • 40
  • 60
3

start with:

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

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

CD..
  • 72,281
  • 25
  • 154
  • 163
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
  • 15,274
  • 1
  • 42
  • 75