-1

I have to do an auto validate stuff, so I must put .blur() and .focus() event handlers on input fields which have the 'checkMe' prefix in their class attribute, so they will look alike 'class="checkMe-required"', 'class="checkMe-mustBeInt"', 'class="checkMe-mustBeDate"' and so on. How to do this? This $('.checkMe-*').focus(function() { aint work...

James Allardice
  • 164,175
  • 21
  • 332
  • 312
John Smith
  • 6,129
  • 12
  • 68
  • 123

1 Answers1

2

Use the "starts-with" selector:

$("[class^='checkMe']")

However, performance-wise, it would probably be better to have a checkMe class and add the other part as a second class:

<input class="checkMe required" type="text>

Then you can use the normal class selector:

$(".checkMe")
James Allardice
  • 164,175
  • 21
  • 332
  • 312