IE6 <Option/> selected属性设置问题

本文解决了一个在Internet Explorer 6浏览器中使用jQuery设置元素selected属性时出现的未指明错误问题。通过使用setTimeout延迟执行设置selected属性的方法,成功地避免了IE6中的脚本错误。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

在IE6下,弹出脚本错误的提示:无法设置selected属性 未指明的错误

jQuery(this).attr("selected", true);

 修复方式

setTimeout(function(){
      jQuery(this).attr("selected", true);
}, 0);

 

<form id="inputForm" action="update.jhtml" method="post" type="ajax" validate-type="validate" style="width: 100%"> <input type="hidden" name="id" value="${followUpRecord.id}" /> <div class="tabContent"> <table class="input input-edit"> <tr> <th> <span class="requiredField">*</span>${message("跟进类型")}: </th> <td colspan="2"> <select class="text followType" name="followType" id="followType" required btn-fun="clear"> <option value="">--请选择--</option> <option value="1" [#if followUpRecord.followType == 1] selected [/#if]>商机跟进</option> <option value="2" [#if followUpRecord.followType == 2] selected [/#if]>客户跟进</option> </select> </td> <th> <span class="requiredField">*</span>${message("跟进对象")}: </th> <td colspan="2"> <span class="search" style="position:relative"> <input type="hidden" id="objId" name="objId" class="text objId" value="${followUpRecord.objId}" btn-fun="clear" required/> <input type="text" id="objName" name="objName" class="text objName" value="${followUpRecord.objName}" onkeyup="clearSelect(this)" required/> <input type="button" class="iconSearch" value="" id="selectObj"> </span> </td> <th class="t_projectStageValue" style="display: none;"> ${message("商机阶段")}: </th> <td class="t_projectStageValue" style="display: none;"> <input type="text" name="projectStageValue" class="text projectStageValue" maxlength="200" value="${followUpRecord.projectStageValue}"/> </td> <th> <span class="requiredField">*</span>${message("状态")}: </th> <td colspan="2"> <select class="text recordStatus" name="recordStatus" required btn-fun="clear" style="pointer-events: none;background-color: #f7f7f7"> <option value="1" [#if followUpRecord.recordStatus == 1] selected [/#if]>未提交</option> <option value="2" [#if followUpRecord.recordStatus == 2] selected [/#if]>已提交</option> <option value="3" [#if followUpRecord.recordStatus == 3] selected [/#if]>审批中</option> </select> </td> </tr> <tr> <th> ${message("标段划分")}: </th> <td> <input type="text" name="sectionDivision" class="text sectionDivision" maxlength="200" /> </td> <th> ${message("跟进阶段")}: </th> <td> <select class="text followUpState" name="followUpState" id="followUpState" required btn-fun="clear"> <option value="">--请选择--</option> [#list followUpStates as followUpState] <option value="${followUpState.value}" [#if followUpRecord.followUpState == followUpState.value] selected [/#if] >${followUpState.remark}</option> [/#list] [#-- <option value="1" [#if followUpRecord.followUpState == 1] selected [/#if]>发现阶段</option>--] [#-- <option value="2" [#if followUpRecord.followUpState == 2] selected [/#if]>客户接触阶段</option>--] [#-- <option value="3" [#if followUpRecord.followUpState == 3] selected [/#if]>需求了解阶段</option>--] [#-- <option value="4" [#if followUpRecord.followUpState == 4] selected [/#if]>评估阶段</option>--] </select> </td> <th> ${message("是否关闭商机")}: </th> <td> <select class="text isCloseNiche" name="isCloseNiche" id="isCloseNiche" required btn-fun="clear"> <option value="">--请选择--</option> <option value="1" [#if followUpRecord.isCloseNiche == 1] selected [/#if]>否</option> <option value="2" [#if followUpRecord.isCloseNiche == 2] selected [/#if]>是</option> </select> </td> </tr> <tr> <th> ${message("项目进度详细描述")}: </th> <td colspan=" 10" style="width: 95%"> <textarea name="projectScheduleDescription" class="text projectScheduleDescription" cols="30" rows="2"/>${followUpRecord.projectScheduleDescription}</textarea> </td> </tr> <tr> <th> ${message("项目运作思路及关键点")}: </th> <td colspan="10" style="width: 95%"> <textarea name="ideaPoint" class="text ideaPoint" cols="30" rows="2"/>${followUpRecord.ideaPoint}</textarea> </td> </tr> <tr> <th> ${message("下一步工作计划")}: </th> <td colspan="10" style="width: 95%"> <textarea name="nextPlan" class="text nextPlan" cols="15" rows="2"/>${followUpRecord.nextPlan} </textarea> </td> </tr> <tr> <th> ${message("需公司其他部门支撑事项")}: </th> <td colspan="10" style="width: 95%"> <textarea name="needBackup" class="text needBackup" cols="15" rows="2"/>${followUpRecord.needBackup}</textarea> </td> </tr> <tr> <th> <span class="requiredField">*</span>${message("总结")}: </th> <td colspan="10" style="width: 95%"> <textarea cols="20" rows="2" name="sumUp" class="text sumUp" required/>${followUpRecord.sumUp} </textarea> </td> </tr> <tr style="display: none" class="t_closeResult"> <th> <span class="requiredField" >*</span>${message("商机关闭原因")}: </th> <td colspan=" 10" style="width: 95%"> <textarea name="closeResult" class="text closeResult" cols="30" rows="2" [#if followUpRecord.isCloseNiche == 2] required [/#if]/>${followUpRecord.closeResult}</textarea> </td> </tr> <tr> <th>${message("图片")}</th> <td colspan="10" style="width: 95%"> <div class="box-wrap"> <div class="box-main" style="overflow:visible;"> <div class="upload-list tc" style="overflow:initial;width:260px;"> [#list followUpRecord.images as image] <div class="ul-box" style="padding:13px 0px 0px"> <div class="pic" style="margin-left:65px; width:80px"><a href="${image.source}" target="_blank"><img src="${image.thumbnail}"></a></div> <b> </b> <a class="del delProductImage1" href="#"></a> <input type="hidden" name="images[${image_index}].title" value="${image.title}"> <input type="hidden" name="images[${image_index}].source" value="${image.source}"> <input type="hidden" name="images[${image_index}].large" value="${image.large}"> <input type="hidden" name="images[${image_index}].medium" value="${image.medium}"> <input type="hidden" name="images[${image_index}].thumbnail" value="${image.thumbnail}"> </div> [/#list] <a href="javascript:;" class="a-upload" id="addProductImage"></a> </div> </div> </div> </td> </tr> </table> <div> <table> <tr> <th>111</th> <td> <textarea rows="2" cols="30"></textarea> </td> </tr> </table> </div> <div class="task-content"> [#include "/crm/follow_up_record/edit/task-form.ftl" /] </div> <br/> <div class="title-style"> 附件上传: <div class="btns"> <a href="javascript:;" id="addAttach" class="button">添加附件</a> </div> </div> <table id="table-attach"></table> <div class="title-style"> 抄送人: <div class="btns"> <a href="javascript:;" id="addMember" class="button">添加抄送人</a> </div> </div> <table id="table-addMember"></table> <div class="title-style"> 定位:提示:你可以放大地图以便更准确标记。 </div> <div> <table class="input tabContent"> <tr> <td colspan="4" style="line-height: 25px;padding: 5px;border-bottom: 1px solid #dde9f5;"> <!-- <span class="fieldSet"> <input type="hidden" id="areaId" name="areaId" /> </span>   详细地址:<input type="text" name="address" class="txt" maxlength="200"/> --> <br/> 定位地址:<input type="text" id="searchText" style="line-height: 20px;width: 400px;border: solid 1px #dcdcdc;"/> <input type="button" value="搜索" id="searchButton" style="border: revert;"/>    详细地址:<input type="text" id="address" name="address" readonly="readonly" value="${followUpRecord.address}" style="line-height: 20px;width: 400px;border: solid 1px #dcdcdc;"/> 经度:<input type="text" name="longitude" id="mapy" readonly="readonly" value="${followUpRecord.longitude}" style="line-height: 20px;border: solid 1px #dcdcdc;"/>   纬度:<input type="text" name="latitude" id="mapx" readonly="readonly" value="${followUpRecord.latitude}" style="line-height: 20px;border: solid 1px #dcdcdc;"/> </td> </tr> <tr> <td style="height:400px;display:block;" colspan="3"> <div id="allmap"></div> </td> <td style="height:400px;"> <ul id="searchResUl"> </ul> </td> <tr> </table> </div> </div> <div class="fixed-top"> [#if followUpRecord.recordStatus == 1] [#if followUpRecord.isCloseNiche != 2] <a href="javascript:void(0);" class="button sureButton" onclick="submitData(this)">${message("提交")}</a> [/#if] <a href="javascript:void(0);" class="button sureButton" onclick="save(this)">${message("保存")}</a> [#if followUpRecord.isCloseNiche == 2 && followUpRecord.wfState == 0] <a href="javascript:void(0);" class="button sureButton" onclick="check_wf(this)">${message("12501")}</a> [/#if] [/#if] <input type="button" onclick="location.reload(true);" class="button resetButton ml15" value="${message("重置")}"> </div> </form>修改该代码 使得文本框能使用回车换行并出现滚动条
07-31
<div class="form-group"> <label class="col-sm-2 control-label"><i></i> 设置类型:</label> <div class="col-sm-10"> <label class="radio-inline i-checks"> <input name="type" type="radio" value="byPersonnel" th:text="按人员设置" th:checked="true"> </label> <label class="radio-inline i-checks"> <input name="type" type="radio" value="byCategory" th:text="按分类设置"> </label> </div> </div>我想给这个设置类型代码加一个选择事件,选择人员设置显示<div class="form-group"> <label class="col-sm-2 control-label"><i>*</i> 人员设置:</label> <div class="col-sm-8"> <div class="col-sm-4"> <button class="btn btn-primary select-teacher" type="button" onclick="selectTeacher()"> 添加教师 </button> <a class="teacherNumber" style="margin-left: 10px"></a> </div> <div class="col-sm-4"> <button class="btn btn-primary select-student" type="button" onclick="selectStudent()"> 添加学生 </button> <a class="studentNumber" style="margin-left: 10px"></a> </div> </div> </div>这块代码,如果选择分类设置显示<div class="form-group"> <label class="col-sm-3 control-label"><i>*</i> 选择分类:</label> <div class="col-sm-8"> <select id="productId" name="productId" class="form-control" > <option th:value="" disabled selected hidden="hidden">请选择分类</option> <option th:value="boarder">住宿生</option> <option th:value="extern">走读生</option> <option th:value="faculty">教职工</option> </select> </div> </div>这块代码,该怎么弄
03-25
<!DOCTYPE html> <html xmlns:th="http://www.thymeleaf.org"> <head> <meta charset="utf-8" /> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no"> <title>休暇申請</title> <th:block th:replace="css.html"/> <style> h5{display:inline-block;}.modal-body,.modal-body p{font-size:14px;}#tipId{margin-top:-12px; margin-left:16px;}.color-input-disabled{color:#2f4154;} </style> </head> <body> <th:block th:replace="menu.html"/> <div class="header-6"> <div class="header-blur"></div> <div id="particles-js" class="header-particles"></div> <div class="header-inner"> <h2 class="header-title">休暇申請</h2> </div> </div> <div class="container content" style="transition: height 1s ease"> <div class="content-wrapper"> <div class="row margin-bottom-30"> <div class="col-auto"> <h5>休暇申請</h5> <input id="tipId" class="btn btn-info btn-xs" type="button" value="説明"> </div> </div> <!-- form --> <form role="form" th:action="@{/leave/submit}" th:object="${leaveApplyForm}" method="post" id="applyForm"> <div class="row"> <div class="col-md-2 col-sm-4 form-group"> <label class="col-form-label label-gray">開始日付</label> <font class="text-danger">※</font> </div> <div class="col-md-4 col-sm-4 form-group"> <input type="text" id="restDate" th:field="*{startDate}" autocomplete="off" class="form-control datetimepicker" placeholder="年/月/日"> </div> </div> <div class="row"> <div class="col-md-2 col-sm-4 form-group"> <label class="col-form-label label-gray">休暇時間</label> <font class="text-danger">※</font> </div> <div class="col-md-2 col-sm-4 form-group after-day"> <input type="text" id="restDays" th:field="*{restDays}" autocomplete="off" class="form-control textbox" placeholder="1日単位"/> </div> <div class="col-md-2 col-sm-4 form-group after-hour"> <input type="text" id="restHours" th:field="*{restHours}" autocomplete="off" class="form-control textbox" placeholder="1時間単位"/> </div> </div> <div class="row"> <div class="col-md-2 col-sm-4 form-group"> <label class="col-form-label label-gray">有給使用時間</label> </div> <div class="col-md-2 col-sm-4 form-group after-day"> <input type="text" id="paidDays" th:field="*{paidDays}" autocomplete="off" class="form-control textbox" placeholder="1日単位"/> </div> <div class="col-md-2 col-sm-4 form-group after-hour"> <input type="text" id="paidHours" th:field="*{paidHours}" autocomplete="off" class="form-control textbox" placeholder="1時間単位"/> </div> </div> <div class="row"> <div class="col-md-2 form-group"> <label class="col-form-label label-gray">特別休暇使用時間</label> </div> <div class="col-md-4 form-group"> <div id="specialRest" class="form-control custom-selector"></div> <select id="specialRest" th:field="*{specialRest}"> <option value=""> </option> <option th:each="item : ${T(jp.co.yangtze.common.enums.SpecialRestReason).values()}" th:value="${item.getCode()}" th:selected="${item.getCode()} == *{specialRest}" th:text="${item.getLabel()}"></option> </select> </div> <div class="col-md-2 col-sm-3 form-group after-day"> <input type="text" id="specialDays" th:field="*{specialDays}" autocomplete="off" disabled class="form-control textbox" placeholder="1日単位"/> </div> <div class="col-md-2 col-sm-3 form-group after-hour"> <input type="text" id="specialHours" th:field="*{specialHours}" autocomplete="off" disabled class="form-control textbox" placeholder="1時間単位"/> </div> </div> <div class="row"> <div class="col-md-2 form-group"> <label class="col-form-label label-gray">休暇理由</label> <font class="text-danger">※</font> </div> <div class="col-md-4 form-group"> <div id="reasonCode" class="form-control custom-selector"></div> <select id="reasonCode" th:field="*{reasonCode}"> <option value=""> </option> <option th:each="item : ${T(jp.co.yangtze.common.enums.RestReason).values()}" th:value="${item.getCode()}" th:selected="${item.getCode()} == *{reasonCode}" th:text="${item.getLabel()}"></option> </select> </div> </div> <div class="row"> <div class="col-md-2 form-group"> <label class="col-form-label label-gray">備考</label> </div> <div class="col-md-10 form-group"> <input type="text" id="remark" th:field="*{remark}" class="form-control textbox" autocomplete="off" placeholder="備考"></input> </div> </div> </form> <div class="row margin-top-30"> <div class="col-md-3 offset-md-2 form-group"> <button id="apply" class="btn btn-block btn-info" type="button">申請</button> </div> <div class="col-md-3 offset-md-2 form-group"> <button id="back" class="btn btn-block btn-info" type="button">戻る</button> </div> </div> </div> </div> <div class="modal fade" id="restRuleModal" tabInx="-1" aria-labelledby="mydelby" role="dialog" aria-hidden="true"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <h6 class="modal-title" id="myModalLabel">休暇申請説明</h6> </div> <div class="modal-body"> <p>数字は半角で入力してください;</p> <p>休暇時間=有給使用時間+特別休暇使用時間;</p> <p>特別休暇使用の説明:</p> <p>1親等→父母、配偶者、子女;</p> <p>2親等→祖父母、配偶者の父母、及び兄弟姉妹;</p> </div> <div class="modal-footer"> <button class="btn btn-primary" data-dismiss="modal">確認</button> </div> </div> </div> </div> <th:block th:replace="footer.html" /> <th:block th:replace="js.html" /> <th:block th:replace="chose_approver.html"/> <script th:inline="javascript"> var overtime = /*[[${overtime}]]*/ 0; console.log("Remaining hours:", overtime); </script> <script> $(document).ready(function() { //特別休暇制御 if($("select#specialRest").val().trim().length !== 0) { $("#specialDays").removeAttr("disabled"); $("#specialHours").removeAttr("disabled"); } else { $("#specialDays").attr("disabled","true"); $("#specialHours").attr("disabled","true"); } $("#tipId").click(function() { $("#restRuleModal").modal(); }); // 申請 $("#apply").click(function(){ $("#choseApproverModal").modal(); approvePermission = "leave:manage"; }); // 戻る $("#back").click(function() { $("#applyForm").attr('action', '/leave/back'); $("#applyForm").attr('method', 'get'); $("#applyForm").submit(); }); $("select#specialRest").change(function() { if(this.value.trim().length !== 0) { $("#specialDays").removeAttr("disabled"); $("#specialHours").removeAttr("disabled"); } else { $("#specialDays").attr("disabled","true"); $("#specialHours").attr("disabled","true"); $("#specialDays").val(""); $("#specialHours").val(""); } }); }); //20250521 mod by soki start /*function onApproverChosed(approverId){ $("#applyForm").attr('action', '/leave/submit'); $("#applyForm").attr('method', 'post'); $("#applyForm").append($('<input />', { type: 'hidden', name: 'approverId', value: approverId, })); $(window).rippleLoading(); $("#applyForm").submit(); }*/ //var overMessage = ' /*[[${overMessage}]]*/ '; function onApproverChosed(approverId) { console.log(overtime); // 新增条件判断(修改点1) if (overtime < 0) { // 弹出确认对话框(修改点2) $(window).confirmDialog({ info: '有給残時間はマイナスとなります、申請後有給残時間:', confirmText: "はい", cancleText: "キャンセル", confirmCallback: function() { // 确认后执行原逻辑(修改点3) doFormSubmit(approverId); }, cancelCallback: function() { // 取消时停止(修改点4) $(window).rippleLoading("hide"); // 可选的加载动画关闭 } }); } else { // 无消息时直接提交(修改点5) doFormSubmit(approverId); } } // 新增公共提交方法(修改点6) function doFormSubmit(approverId) { // 先清空可能存在的旧字段(修改点7) $("#applyForm input[name='approverId']").remove(); $("#applyForm") .attr('action', '/leave/submit') .attr('method', 'post') .append($('<input />', { type: 'hidden', name: 'approverId', value: approverId })); $(window).rippleLoading(); // 显示加载动画 $("#applyForm").submit(); } //20250521 mod by soki end </script> </body> </html>这是我前端代码,帮我分析一下
05-22
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值