HTML中选择性点击,如何通过HTML循环选择<option>点击值?

在日历应用程序中,我有一个简单的选择,其选项标签的值为0-11,相应的月份。我可以在单月(从十二月到一月)周而复始,但我无法以其他方式工作。它只显示2月和12月。如何通过HTML循环选择点击值?

这里的a jsfiddle显示我已经做了什么。

这里的HTML:

January

February

March

April

May

Month

这里是jQuery的:

$('.chevron').on('click', function() {

// This if works perfectly, and will reset to 11 once the selectedMonth is 0

if ($(this).hasClass('chevronLeft')) {

var selectedMonth = $('#MonthName').val();

(selectedMonth != 0)

? $('#MonthName').val(selectedMonth - 1).trigger('change')

: $('#MonthName').val(11).trigger('change');

}

else {

// This doesn't work, I tried declaring the variable locally,

// different less/greater than expressions, but nothing works

var selectedMonth = $('#MonthName').val();

(selectedMonth !== 11)

? $('#MonthName').val(selectedMonth + 1).trigger('change')

: $('#MonthName').val(0).trigger('change');

}

});

$('#MonthName').on('change', function() {

var monthText =

$('#MonthName option:selected').text();

$('.theMonth').text(monthText);

});

<view class="approval" style="margin-bottom: 2%;"> <button v-if="!isApproving" @click="Approval" class="approval-btn"> <text class="text-approval">批量审批</text> </button> <view v-else class="selection" style="display: flex; margin-left: 30%;"> <view style="position: absolute;left: 5%;display: flex;margin-top: 4%;"> <image style="width: 40rpx;height: 40rpx;" src="/static/images/pick2.png"></image> <text style="color: #afafaf;"> 全选</text> </view> <view style="width: 25%;"> <button @click="ApprovalCancel" type="primary" plain="true" class="btn-cancel">取消</button> </view> <view style="width: 35%;position: absolute;right: 5%;"> <button type="primary" class="btn-approval">审批</button> </view> </view> </view> <uni-swipe-action> <uni-swipe-action-item :left-options="options" :show="isOpened" :auto-close="false"> <uni-card title="人力资源专员" sub-title="泥膜事业部" extra="26人" :thumbnail="avatar" @click="onClick"> <view><text class="uni-body">到岗时间:2025年-10月中旬</text></view> <view><text class="uni-body">需求原因:</text></view> </uni-card> </uni-swipe-action-item> </uni-swipe-action> data() { return { show: true, isApproving: false, url: '', isOpened: 'none', text: "ss", options: [{ // style:{ // backgroundColor:'transparent' // } isImage: true, src: 'https://pic1.imgdb.cn/item/67cf9c9a066befcec6e2b360.png', style: { backgroundColor: 'transparent', imgWidth: '40rpx', imgHeight: '40rpx' } }], }; }, 这里的option是一个类似于空的未选择圆形复选框图片,我想点击这个图片切换成另一张图片,请在原又的基础上更改
03-27
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值