开发者

Why is daterangepicker using every field type?

I've just tried the daterangepicker and for some reason it uses every for开发者_如何学JAVAm and button I have on my site. Why is this? Is there a better alternative? Thanks :)))

Here's what I have


It appears that plugin does not properly handle selectors that target multiple elements.

Just as a quick work-around, try this (not tested, but should work):

$('input').each(function() {
    $(this).daterangepicker({arrows:false});
}

Note that this will apply the picker to all input elements, but each one is controlled individually rather than all inputs being updated by a single picker.

If you wish to target only a single input, you need to give that input a unique ID or class and update your selector to target it (e.g. #my_datepicker or .my_datepicker)


It's because of the function below. You are using $('input') as the selector, which means all input elements. Since you have 3 input elements on your form and all 3 of them get the daterangepicker. For selectively applying it to elements, change your selector to be an id or class i.e. $('#myId').daterangepicker() or $('.myclass').daterangepicker().

$(function(){
              $('input').daterangepicker({arrows:false}); 
         });


this piece of code: $('input') selects all elements with a tagName of input. That is why the plugin is applied to all elements with a tagName of input.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜