SURTLER77
SURTLER77

Reputation: 87

add class to input field if name is x

In my website load a js file from commercial service, so I don't have possibility to customize this file, the output of this is a form with various input field, every field have the same class name "wf-input", now I want add to a specific field a jquery date picker but don't have a class for select only a one field.

This is a field I want add a datepicker

<input type="text" name="x4" class="wf-input">

Now my request is how add a class name to only this field?

The only difference between field is (name="x4).

The code for initializing datepicker is this:

$(function() {
    $( ".x4picker" ).datepicker();
  });

How make this work with javascript??

Upvotes: 0

Views: 4712

Answers (1)

rrk
rrk

Reputation: 15846

The following should do it.

$( "input[name='x4']" ).datepicker();

and if you still want to add class

$( "input[name='x4']" ).addClass('x4picker').datepicker();

Upvotes: 1

Related Questions