[-][input][+]

http://api.jquery.com/on/

http://api.jquery.com/prev/

 

tip: adding the jqm will wrap the input tab, & prev() doesn't work. add "data-role='none' " in input.

 

 1 <!DOCTYPE html>
 2 <html>
 3 <head>
 4 <script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
 5 <script src="http://code.jquery.com/mobile/1.4.0/jquery.mobile-1.4.0.min.js"></script>
 6 <script>
 7 $().ready(function(){
 8     var max = 7;
 9     $("#stationinfo").on("click",".J_add",function(){
10         var t = $(this).prev(".J_input");
11         if(Number(t.val())< Number(max))
12         {
13             t.val(parseInt(t.val())+1);
14         }                
15     });
16     
17     $("#stationinfo").on("click",".J_minus",function(){
18         var t = $(this).next(".J_input");
19         if(Number(t.val())>0){
20             t.val(parseInt(t.val())-1);
21         }                
22     });
23 });
24 </script>
25 </head>
26 <body>
27     <div id="stationinfo">
28         <a href='javascript:;' class='J_minus'>-</a>
29         <input type='text' class='J_input' value='0' data-role='none'/>
30         <a href='javascript:;' class='J_add'>+</a>
31     </div>
32 </body>
33 </html>
View Code

 

转载于:https://www.cnblogs.com/xiaowangzi2013/p/3825646.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
如果您是在 Vue 中使用 Ant Design 的 Input 和 Select 组件来实现输入时展示多个选项的效果,可以参考以下步骤: 1. 在 Vue 组件中引入 Ant Design 的 Input 和 Select 组件。 ```vue <template> <div> <a-input-search :enter-button="true" @search="handleSearch"> <a-select slot="suffix" v-model="value" :options="options" @change="handleSelect" show-search placeholder="请选择" > <a-select-option v-for="option in options" :key="option.value" :value="option.value" > {{ option.label }} </a-select-option> </a-select> </a-input-search> </div> </template> <script> import { Input, Select } from 'ant-design-vue'; export default { name: 'MultiSelectInput', components: { 'a-input-search': Input.Search, 'a-select': Select, 'a-select-option': Select.Option, }, data() { return { options: [], value: '', }; }, methods: { handleSearch(value) { // 根据输入内容获取选项数据 const options = getOptions(value); this.options = options; }, handleSelect(value) { // 将选项的值填充到输入框中 this.value = value; }, }, }; </script> ``` 在上面的示例代码中,我们在 Vue 组件中引入了 Ant Design 的 Input 和 Select 组件,并且使用了 Input.Search 和 Select 组件结合的方式来实现输入时展示多个选项的效果。当用户输入内容后,我们通过调用 handleSearch 方法来获取选项数据,并且将 options 属性设置为获取到的选项数据。当用户选择某个选项后,我们通过调用 handleSelect 方法来将选项的值填充到输入框中。 需要注意的是,上面的示例代码中使用了 Ant Design Vue 中的组件,因此需要先安装并引入 Ant Design Vue 库。另外,示例中的 getOptions 方法需要根据具体的业务逻辑实现,用于根据输入内容获取选项数据。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值