jquery如何实现进入页面只展示对应的字段数据 用户点击编辑之后所有的input select才可以编辑,求个思路

jquery如何实现进入页面只展示对应的字段数据 用户点击编辑之后所有的input select才可以编辑,求个思路

阅读 1.8k
2 个回答
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Document</title>
  <style type="text/css">
    
  </style>
</head>
<body>

  <input type="text">
  <input type="text">
  <input type="text">

  <button class="btn1">增加</button>
  <button class="btn2">移除</button>

  <script src="js/jquery.min.js"></script>
  <script>
      $(".btn1").click(function(){
          $(":input").attr("readonly","readonly");
      })
      $(".btn2").click(function(){
          $(":input").removeAttr("readonly");
      })

  </script>
</body>
</html>
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题