万年荔枝 2022-04-03 11:45 采纳率: 60%
浏览 208
已结题

火狐报错:Uncaught SyntaxError: missing ( before formal parameters 怎么解决

问题代码:

<!DOCTYPE html>
<html lang="en">

<head>
  <style>
    .box {
      position: relative;
      width: 400px;
      border-bottom: 1px solid #ccc;
      margin: 100px auto;
    }

    .box input {
      width: 370px;
      height: 30px;
      border: 0;
      outline: none;
    }

    .box img {
      position: absolute;
      top: 2px;
      right: 2px;
      width: 24px;
    }
  </style>
</head>

<body>
  <!--正文-->
  <div class="box">
    <img
      src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg-qn.51miz.com%2FElement%2F00%2F90%2F38%2F24%2Fce87f342_E903824_e765706b.png&refer=http%3A%2F%2Fimg-qn.51miz.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1651545581&t=72527a6535d3fb3c144fca140729c2c5"
      id="eye">
    <input type="password" id="pwd">
  </div>


  <script>
    var eye = document.getElementById('eye');
    var pwd = document.getElementById('pwd');

    eye.onclick = function {
      pwd.type = 'text';
    }
  </script>
</body>

</html>

目标是实现一个点击图片后,密码栏改变格式。但是实际应用的时候点图片没反应,浏览器报错
“Uncaught SyntaxError: missing ( before formal parameters”


还有一个问题,就是给图片套上一个lable(如下)有什么意义
我加上之后甚至多报了一个错

img

<!DOCTYPE html>
<html lang="en">

<head>
  <style>
    .box {
      position: relative;
      width: 400px;
      border-bottom: 1px solid #ccc;
      margin: 100px auto;
    }

    .box input {
      width: 370px;
      height: 30px;
      border: 0;
      outline: none;
    }

    .box img {
      position: absolute;
      top: 2px;
      right: 2px;
      width: 24px;
    }
  </style>
</head>

<body>
  <!--正文-->
  <div class="box">
    <lable for="">
      <img
      src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg-qn.51miz.com%2FElement%2F00%2F90%2F38%2F24%2Fce87f342_E903824_e765706b.png&refer=http%3A%2F%2Fimg-qn.51miz.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1651545581&t=72527a6535d3fb3c144fca140729c2c5"   id="eye">
    </lable>
    <input type="password" id="pwd">
  </div>


  <script>
    var eye = document.getElementById('eye');
    var pwd = document.getElementById('pwd');

    eye.onclick = function {
      pwd.type = 'text';
    }
  </script>
</body>

</html>
  • 写回答

2条回答 默认 最新

  • 嘉祐-小萝卜算子 2022-04-03 11:54
    关注

    少了个括号

    img

    
    <script>
        var eye = document.getElementById('eye');
        var pwd = document.getElementById('pwd');
     
        eye.onclick = function() {
          pwd.type = 'text';
        }
      </script>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

问题事件

  • 系统已结题 4月11日
  • 已采纳回答 4月3日
  • 创建了问题 4月3日

悬赏问题

  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘