如何加载 Jquery

How To Load Jquery

所以我有THIS FIDDLE

这就是我想要的效果。但是,问题是我无法让它在我的网站上运行。我有

$( ".total" ).change(function hello() { 
   140 Lines of code from fiddle
}


在我的 body 中的脚本标签之间。
我有

<script src="/jquery-3.1.1.min.js">< /script>

在我的脑海里。我已经下载了 jquery,它在我的 public_html 中(godaddy 托管在 linux cpanel 中)你可以看到它在我的 SITE
我的 body 标签看起来像这样

<body onload="hello()">

我的代码是从 fiddle 中直接复制和粘贴的。 table 的第一行看起来像这样

<label id="printchatbox" ></label>
<table>
 <tr>
   <td>
     <input type="number" class="total" name='barrelwrap' value "<?=isset($_POST['barrelwrap']) ? htmlspecialchars($_POST['barrelwrap']) : '' ?>">
   </td>
   <td>Barrel Wrap 47"x31" </td>
   <td id='barrelwrapPrice'>39.38 </td>
  <tr>
   <td>
    <input type="number" class="total" name="smallcase" value "<?= isset($_POST['smallcase']) ? htmlspecialchars($_POST['smallcase']) : '' ?>">
   </td>
   <td>Case Card - Small 4.25"x11" </td>
   <td id='smallcasePrice'>1.50 </td>
  </tr>

我的脚本的第一行,再次复制并粘贴。

$( ".total" ).change(function hello() {
 var barrelwrapInput = document.getElementsByName('barrelwrap')[0];
 var smallcaseInput = document.getElementsByName('smallcase')[0];
 var mediumcaseInput = document.getElementsByName('mediumcase')[0];
 var largecaseInput = document.getElementsByName('largecase')[0];
 var coolerclingInput = document.getElementsByName('coolercling')[0];
 var poletopperInput = document.getElementsByName('poletopper')[0];
 var smallflyerInput = document.getElementsByName('smallflyer')[0];
 var largerflyerInput = document.getElementsByName('largerflyer')[0];
 var shelftagInput = document.getElementsByName('shelftag')[0];
 var stanchionInput = document.getElementsByName('stanchion')[0];
 var smallwindowInput = document.getElementsByName('smallwindow')[0];

有人知道我做错了什么吗?

Even though the file is on your site, you may not be referencing it correctly. Different servers have different configurations and requirements that may affect whether these reference rules work or not.

例如,GoDaddy 虚拟主机通常在网站的根目录下提供一个 "httpDocs" 文件夹。您不必使用它,但这是他们的服务器希望放置网站内容的地方。不遵守这些规则会导致相对路径不起作用。

但是,在我们深入探讨之前。您是否尝试过从托管来源链接到 JQuery,例如:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

如果使用这个有效,那么问题肯定是您对本地 JQuery 文件的引用。如果是这样,请继续阅读...

如果你需要的资源是同一个网站的一部分(这里不谈文件夹结构,谈域),你应该使用相对路径,其中:

一个。如果资源与当前加载的文档位于同一文件夹中,fileName.ext 就是您所需要的。

b。 folderName/fileName.ext 如果您需要的文件位于加载文档所在的当前文件夹的子文件夹中,那么您需要的是

c。 ../fileName.ext 是如果您需要的文件比当前文档文件夹高一个目录时使用的内容。如果您需要上升一个以上级别(即 ../../fileName.ext),可以重复 ../。[=​​13=]

d。 /fileNameext/folderName/fileName.ext 表示指定的文件或文件夹应该从网站的根目录开始,无论当前文档在哪里。 如果您需要的资源位于另一个域中,您将使用绝对路径 (http://something.something/file.ext)。

e。 不要对本地资源使用绝对路径!这可能有效,但会导致必须再次解析域名,从而导致加载时间更长。

警告:许多服务器托管在具有区分大小写文件系统的操作系统上,因此请始终以实际使用的相同大小写引用文件和文件夹。同样,在您开发时(因为您还没有将文件移动到远程服务器),在本地不这样做可能对您有用,但不要让它让您认为这种情况无关紧要。