我的 <head> 或 <script> 是不是做错了什么
Am I doing something wrong with my <head> or <script>
我想知道我是否对我的标签或标签做了一些奇怪的事情。我有一些脚本,不正确 运行,但适用于 JS fiddle。这是代码:
<head>
<title>Website</title>
<link rel="stylesheet" href="style.css">
<link href="https://fonts.googleapis.com/css?family=Quicksand" rel="stylesheet">
<script>
(function(){
var parallax = document.querySelectorAll("#textPlaceOne"),
speed = -0.5;
window.onscroll = function(){
[].slice.call(parallax).forEach(function(el,i){
var windowYOffset = window.pageYOffset,
elBackgrounPos = "50% " + (windowYOffset * speed) + "px";
el.style.backgroundPosition = elBackgrounPos;
});
};
})();
</script>
</head>
可能有些愚蠢,但如果您能提供帮助,谢谢!
在页面底部 body 标签后写下您的脚本标签。
如果问题仍然存在,请在脚本的第一行写入 debug;
并在 Chrome 中打开页面。按 f12,chrome 会让你调试问题。
我想知道我是否对我的标签或标签做了一些奇怪的事情。我有一些脚本,不正确 运行,但适用于 JS fiddle。这是代码:
<head>
<title>Website</title>
<link rel="stylesheet" href="style.css">
<link href="https://fonts.googleapis.com/css?family=Quicksand" rel="stylesheet">
<script>
(function(){
var parallax = document.querySelectorAll("#textPlaceOne"),
speed = -0.5;
window.onscroll = function(){
[].slice.call(parallax).forEach(function(el,i){
var windowYOffset = window.pageYOffset,
elBackgrounPos = "50% " + (windowYOffset * speed) + "px";
el.style.backgroundPosition = elBackgrounPos;
});
};
})();
</script>
</head>
可能有些愚蠢,但如果您能提供帮助,谢谢!
在页面底部 body 标签后写下您的脚本标签。
如果问题仍然存在,请在脚本的第一行写入 debug;
并在 Chrome 中打开页面。按 f12,chrome 会让你调试问题。