1.后台發送的數據 是spring框架中的對象model.addObject(“student”,stu);
前台頁面由隱藏的接收對象
頁面代碼:
<input id="wfsi" class="hidden" th:value="${student.age}"/>
<div>
<input id="ckbx" type="checkbox"/>
</div>
- 1
- 2
- 3
- 4
- 5
jq代碼設置checkbox的幾種方式:
1.attr
//設置復選框為勾選狀態
$("#ckbx").attr("checked","checked");
//設置復選框未選中狀態
$("#ckbx").removeAttr("checked");
2.prop
//設置復選框為勾選狀態
$("#ckbx").prop("checked",true);
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
以上是在jq.1.12.4.js和bootstrap環境下運行,具體行為是前端html頁面發送請求到controller,springBoot自動獲取對應的數據進行處理,將返回的結果對象(Model以及addObject方法)傳回給html,然后jq獲取負責接收數據的input標簽的值。
<li class="tool-item tool-active is-like "><a href="javascript:;"><svg class="icon" aria-hidden="true">
<use xlink:href="#csdnc-thumbsup"></use>
</svg><span class="name">點贊</span>
<span class="count">2</span>
</a></li>
<li class="tool-item tool-active is-collection "><a href="javascript:;" data-report-click="{"mod":"popu_824"}"><svg class="icon" aria-hidden="true">
<use xlink:href="#icon-csdnc-Collection-G"></use>
</svg><span class="name">收藏</span></a></li>
<li class="tool-item tool-active is-share"><a href="javascript:;"><svg class="icon" aria-hidden="true">
<use xlink:href="#icon-csdnc-fenxiang"></use>
</svg>分享</a></li>
<!--打賞開始-->
<!--打賞結束-->
<li class="tool-item tool-more">
<a>
<svg t="1575545411852" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5717" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><defs><style type="text/css"></style></defs><path d="M179.176 499.222m-113.245 0a113.245 113.245 0 1 0 226.49 0 113.245 113.245 0 1 0-226.49 0Z" p-id="5718"></path><path d="M509.684 499.222m-113.245 0a113.245 113.245 0 1 0 226.49 0 113.245 113.245 0 1 0-226.49 0Z" p-id="5719"></path><path d="M846.175 499.222m-113.245 0a113.245 113.245 0 1 0 226.49 0 113.245 113.245 0 1 0-226.49 0Z" p-id="5720"></path></svg>
</a>
<ul class="more-box">
<li class="item"><a class="article-report">文章舉報</a></li>
</ul>
</li>
</ul>
</div>
</div>
<div class="person-messagebox">
<div class="left-message"><a href="https://blog.csdn.net/qq_26917447">
<img src="https://profile.csdnimg.cn/D/1/E/3_qq_26917447" class="avatar_pic" username="qq_26917447">
<img src="https://g.csdnimg.cn/static/user-reg-year/1x/5.png" class="user-years">
</a></div>
<div class="middle-message">
<div class="title"><span class="tit"><a href="https://blog.csdn.net/qq_26917447" data-report-click="{"mod":"popu_379"}" target="_blank">食火的埃爾德里奇</a></span>
</div>
<div class="text"><span>發布了46 篇原創文章</span> · <span>獲贊 8</span> · <span>訪問量 7萬+</span></div>
</div>
<div class="right-message">
<a href="https://im.csdn.net/im/main.html?userName=qq_26917447" target="_blank" class="btn btn-sm btn-red-hollow bt-button personal-letter">私信
</a>
<a class="btn btn-sm bt-button personal-watch" data-report-click="{"mod":"popu_379"}">關注</a>
</div>
</div>
</div>
原文鏈接 https://blog.csdn.net/qq_26917447/article/details/78801392
1.開啟disabled,是input不可以編輯
$("#id").attr("disabled","disabled");
2.關閉disabled
$("#id").removeAttr("disabled");
普通js中是這樣寫的,document.getElementById("id").disabled = false;
錯誤寫法:$("#id").attr("disabled","false");