标签:style blog http os io java ar for 2014
需求:完成一个不可以改的dropdown,(符合一定logic)在js中设value,并且提交表单时把值提交到server<script src="jquery-1.11.1.min.js"></script> <form name="frm" method="post"> <select id="sel" name="sel"> <option value="1" >1</option> <option value="2">2</option> <option value="3">3</option> </select> <input type="submit" value="submit" /> </form> <script> $(document).ready(function(){ $("#sel").val(2); $("#sel").attr("readonly","readonly"); }); </script>
<script src="jquery-1.11.1.min.js"></script> <form name="frm" method="post"> <select id="sel" name="sel"> <option value="1" >1</option> <option value="2">2</option> <option value="3">3</option> </select> <input type="submit" value="submit" /> </form> <script> $(document).ready(function(){ $("#sel").val(2); $("#sel").attr("disabled","disabled"); }); </script>
$(document).ready(function(){ $("#sel").closest("form").submit(function () { $("#sel").removeAttr("disabled"); }); $("#sel").val(2); $("#sel").attr("disabled","disabled"); });
标签:style blog http os io java ar for 2014
原文地址:http://blog.csdn.net/lan_liang/article/details/39154009