错误”函数未声明“,用于简单的chrome扩展

时间:2020-06-10 13:04:47

标签: javascript html

$(function(){
    $('#alias').keyup(function(){
        $('#youtuber').html($('#alias').val());
    });
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="width=device-width">
    <title>Julius extension</title>
    <script src="jquery.min.js"></script>
    <script src="popup.js"></script>
    <style>
        body{
            width: 300px;
        }
    </style>
</head>
<body>
    <h3>Find your YouTuber: <span id="youtuber"></span> </h3>
    <input id="alias" placeholder="Search your youtuber"/>
</body>
</html>

我正在尝试编写一个简单的chrome扩展名。现在,我希望我在模板的搜索栏中写的所有内容都在“查找YouTuber:”文本之后显示在上方。 但是,由于某些原因(并非如此),我在运行扩展程序时收到错误消息:popup.js:1 (anonymous function)

popuph.html:

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="width=device-width">
    <title>Julius extension</title>
    <script src="jquery.min.js"></script>
    <script src="popup.js"></script>
    <style>
      body{
          width: 300px;
      }
    </style>
  </head>
  <body>
    <h3>Find your YouTuber: <span id="youtuber"></span> </h3>
    <input id="alias" placeholder="Search your youtuber"/>
  </body>
</html>

popup.js:

$(function () {
  $('#alias').keyup(function () {
    $('#youtuber').html($('#alias').val());
  });
});

0 个答案:

没有答案