路径

<!DOCTYPE html>
<html>
<head>
<script src="jquery/jquery-1.11.1.min.js">
</script>
<script>
$(document).ready(function(){
  $("p").click(function(){
    $(this).hide();
  });
});
</script>
</head>
<body>
<p>如果您点击我,我会消失。</p>
<p>点击我,我会消失。</p>
<p>也要点击我哦。</p>
</body>
</html>

在J2EE项目中的jsp文件引用css和js文件时,src=“style/xxx.css” 是项目根目录下的路径,加上/style/xxx.css 就是相对本文件的路径。

在普通的html测试文件时,使用/stype/xxx.css的时候就找不到路径了,去掉/才能在所在目录中找到样式或者js文件。

原文地址:https://www.cnblogs.com/wuxinliulei/p/5198148.html