Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/417.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript html中的脚本标记语法_Javascript_Html - Fatal编程技术网

Javascript html中的脚本标记语法

Javascript html中的脚本标记语法,javascript,html,Javascript,Html,可能重复: 我知道,这是一个非常基本的问题。但我承认我不知道这个问题的答案。我试图在html中包含外部js文件。这是两个案例 <script src="jquery-1_9_0.js"></script><!-- its working --> <script src="jquery-1_9_0.js"/><!-- not working --> 为什么会这样?其中,对于html输入,它在两种情况下都有效 <input

可能重复:

我知道,这是一个非常基本的问题。但我承认我不知道这个问题的答案。我试图在html中包含外部js文件。这是两个案例

<script src="jquery-1_9_0.js"></script><!-- its working -->

<script src="jquery-1_9_0.js"/><!-- not working -->

为什么会这样?其中,对于html输入,它在两种情况下都有效

<input type="text" value="enter value"/><!-- works -->
<input type="text" value="enter value"></input><!-- Also works -->

我能知道原因吗?

C.3。元素最小化和空元素含量
给定内容模型不为空的元素的空实例
(例如,空标题或段落)不要使用
表单(例如,使用

和不使用

)。

来自


这意味着未指定为
空的元素不能自动关闭。

您可以编写


,但不能编写
。将它们视为内容的容器。容器不能自动关闭。

这是因为规范(我懒得链接/查找有关它的信息,可能有人会帮你),所以基本上有些标记需要关闭标记,而其他标记不需要。脚本标记是需要结束标记的标记之一。
C.3. Element Minimization and Empty Element Content

Given an empty instance of an element whose content model is not EMPTY 
(for example, an empty title or paragraph) do not use the minimized 
form (e.g. use <p> </p> and not <p />).
<!ELEMENT script (#PCDATA)>
<!ELEMENT textarea (#PCDATA)>
<!ELEMENT hr EMPTY>
<!ELEMENT br EMPTY>