Mirage
Mirage

Reputation: 31568

Making partial matches with jQuery?

I want to find all input boxes with id containing _date

My code is like this:

<input type="text" name="creation_date" id="id_creation_date" />

Can I use regex for that? Do I need to install something extra for regex to work with jQuery?

Upvotes: 34

Views: 28952

Answers (2)

Bharat Patil
Bharat Patil

Reputation: 1408

If you just want to check ending with "_date" rather than containing "_date" you can use

$('input[id$="_date"]')

Upvotes: 22

jerluc
jerluc

Reputation: 4316

I'm thinking of one of these...

$('input[id*="_date"]').css('background-color', 'red');

Upvotes: 60

Related Questions