简体   繁体   English

我的html代码有什么问题?

[英]what is wrong with my html code?

I am new to html. 我是html的新手。 I have been debugging my code for the past 5 hours and I cannot figure out what is wrong with it. 在过去的5个小时中,我一直在调试我的代码,但我无法弄清楚它出了什么问题。 I reference a package that only has 1 method, which is get_country. 我引用的包只有一种方法,即get_country。 The link to the packages I use are here. 我使用的软件包的链接在这里。 https://github.com/nickewing/line-reader and https://github.com/totemstech/country-reverse-geocoding https://github.com/nickewing/line-readerhttps://github.com/totemstech/country-reverse-geocoding

<html>
  <head>
    <script type="text/javascript">
      function a() {
        var lineReader = require('line-reader');
        lineReader.eachLine(‘Location.txt', function(line, last) {
          var b= line.split(“,”,2)
          var lat= parseInt(b[0])
          var lng= parseInt(b[1])
          var crg = require('country-reverse-geocoding').country_reverse_geocoding();
          var country = crg.get_country(lat, lng);
          console.log(country.name); // 
          if (/* done */) {
            return false; // stop reading
          }
        });
      }
    </script>
  </head>
  <body>
    <button type="button" onclick=“a()>Click run reverse geocoder</button>
  </body>
</html>

You're missing a closing quote, you have: 您缺少结束语,您有:

<button type="button" onclick=“a()>Click run reverse geocoder</button>

and it should be: 它应该是:

<button type="button" onclick="a()">Click run reverse geocoder</button>

Aside from the missing quote in the other answer, you have a few quotes that are not standard or double quotes. 除了其他答案中缺少引号外,您还有一些非标准引号或双引号。 Here are the ones that a JS parser found: 这是JS解析器发现的:

  • lineReader.eachLine('Location.txt... - The single quote before Location is not a single quote lineReader.eachLine('Location.txt... -之前的单引号Location是不是一个单引号
  • var b= line.split(“,” - These are not really double quotes - perhaps convert to single quotes or use actual double quotes var b= line.split(“,” -这些不是真正的双引号-可能转换为单引号或使用实际的双引号

Additionally, after your closing brace to the function, you have some extra closing braces and parenthesis. 此外,在函数的右花括号之后,还有一些额外的右花括号和括号。

  • ); - The parenthesis and semicolon -括号和分号
  • } - The last bracket } -最后一个括号

Hope this helps 希望这可以帮助

  • in javascript or in jQuery try to use "" or '' not that curely “” quotes 在javascript或jQuery中,尝试使用""''而不是“”
  • and its input element in html having attribute type or use button element instead and remove type attribute. 及其在html中具有属性type input元素,或改用button元素并删除type属性。 hope it would work now 希望它现在可以工作

    <html> <head> <script type="text/javascript"> function a() { var lineReader = require('line-reader'); lineReader.eachLine('Location.txt', function(line, last) { var b= line.split(',',2); var lat= parseInt(b[0]); var lng= parseInt(b[1]); var crg = require('country-reverse-geocoding').country_reverse_geocoding(); var country = crg.get_country(lat, lng); console.log(country.name); // if (/* done */) { return false; // stop reading } }); } </script> </head> <body> <input type="button" onclick='a()'>Click run reverse geocoder</button> </body> </html>

EDIT : sorry IDK why the formating of code it not being applied here. 编辑 :对不起IDK,为什么它的代码格式未在此处应用。

语法错误:

onclick="a()" - Missing closing quotes.

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM