JQuery UI datepicker input class

I'm pretty fresh on jQuery and I've just implemented jQuery + jQuery UI, but on the datepicker widget, it seems like the classes added to the input from earlier are being removed and the datepicker classes are being added instead.

How can I save my classes?

+2


source to share


3 answers


It shouldn't remove your classes, but add. You just make sure that you don't (deleting classes) by mistake. Also the code will help me understand your problem more.



0


source


It does not remove existing classes (assuming you are not calling the same one that uses the jQuery UI). But it wraps the tag with additional tags. This way your original input field is a level or two deeper in the DOM tree than before. This is something to be aware of if you are relying on jQuery methods like parent () or sibling () as they are now at a different level.



0


source


Note that the datepicker will add its own unique identifier, which looks something like this: id="dp124326451455"

for each input field that the datepicker is bound to. For this reason, yours should <input >

no longer have id

(which I know you don't, you have class

).

In addition to this weird identifier that is added to each field, it also adds a class called hasDatepicker

. But as Wbdvlpr said, it just adds it to any existing classes you may have. For example, mine has 2 classes myclass

and myclasssec

and looks like: php

<input name="myinputfield" class="myclass myclasssec" type="text" />

      

so it refers to:

<input id="dp1243264511551" name="myinputfield" class="myclass myclasssec hasDatepicker" type="text">

      

Note that only 2 tht changes happened, this is a new id as I said ( id="dp124326451455"

) and a new class that is added to the end of the other classes:class="myclass myclasssec hasDatepicker"

Hope this helps you. But if you need other help, you probably have to post your source so we can help you better.

0


source







All Articles