开发者

jQuery UI datepicker input class

I'm quite fresh on jQu开发者_如何学Cery, and I've just implemented jQuery + jQuery UI, but on the datepicker widget it seems like the classes added on the inputs from before are removed, and datepicker classes are added insteady.

How can I keep my classes as well?


It shouldn't delete your classes but append. You just make sure that you don't do that (removing classes) by mistake. Also a code would help me more to understand your problem.


It doesn't remove existing classes (provided you didn't name the same as what jQuery UI uses). But it does wrap the tag with additional tags. So your original input field is a level or two deeper in the DOM tree than before. It is something to be aware of if you rely on jQuery methods like parent() or sibling() as they are now at a different level.


Note that datepicker will add its own unique id that looks something like this id="dp124326451455" for each input field that has datepicker attached to it. For this reason, your <input > should not already have an id (which I know you don't, you have a class).

In addition to that strange looking id it adds to each field, it also adds a class called hasDatepicker. But as Wbdvlpr said, it just appends it to any existing classes you may have. Mine for example has 2 classes myclass and myclasssec and looks like this in php

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

so it gets turned to:

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

Notice that the only 2 changes tht happened are the new id as I said (id="dp124326451455") and the new class that gets "appended" to the end of the other classes: class="myclass myclasssec hasDatepicker"

Hope it helps you. But if you need other help you probably need to post your source to make easy for us to help you better.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜