Has anyone implemented jQuery Mobile Add (+/-) But

2019-03-25 17:07发布

问题:

This seems like a "must have" form input for a mobile ui framework, but jQuery Mobile doesn't seem to have one.

Has anyone implemented a nice looking number Spinner form input that works well with the other jquery mobile form inputs?

Something like this:

回答1:

Probably well after the fact, but: http://dev.jtsage.com/jQM-Spinbox/ - based pretty much on what you show above, respects jQM themeing, min/max values.



回答2:

It's not exactly the same but an input with type="number" should give you an input field with two small buttons at the right (up & down).

You can check it here.



回答3:

No just the slider input so far.



回答4:

Found this: http://css-tricks.com/number-increment-buttons/



回答5:

<i onclick="qty('plus');" class="fa fa-plus c_pointer"></i>
<input type="text" id="prdqty" name="qty" value="1" placeholder="1">
<i onclick="qty('minus');" class="fa fa-minus c_pointer"></i>



function qty(val){
pqty = $('#prdqty').val();
if (val == "plus") {
      var newVal = parseFloat(pqty) + 1;
    } else {
    if (pqty > 1) {
      var newVal = parseFloat(pqty) - 1;
    } else {
      newVal = 1;
    }
}
$('#prdqty').val(newVal);
}