gpt4 book ai didi

javascript - 我似乎无法链接到我的 .js 文件

转载 作者:行者123 更新时间:2023-11-28 06:34:17 26 4
gpt4 key购买 nike

我正在尝试实现 CSS 和 JS,并将其链接到我的 friend 为我正在从事的项目提供的 HTML 文件。

我已经毫无问题地链接了 CSS,但我尝试链接的 .js 文件无法正常工作。因为脚本无法工作,所以我的 HTML 键盘也无法工作:(

有人注意到我做错了什么吗?

window.pass = 1234;
window.redirectURL = 'http://www.google.com';


$(document).ready(function() {
start();
});


function start() {
window.tries = 0;

$(".key").click(function(){
var n = $(this).html();
$('.screen').append( n );
window.tries++;
updateFlasher();
validate();
});
}

function updateFlasher() {
if (window.tries <=3) {
var dis = window.tries * 55;
$('.flasher').css({
'left' : dis + 'px'
});
}
else {
$('.flasher').css({
'left' : '20px',
'display' : 'none'
});
}
}

function validate() {
if (window.tries >= 4){
checkWin();
$('.screen').html('');
window.tries = 0;
$('.flasher').css({
'display' : 'block'
});
}
}

function checkWin() {
var w = $('.screen').html();
if (w == window.pass){
$('.success').show().delay(5000).queue(function(n) {
$('.success').hide(); n();
});
var u = window.redirectURL;
$(location).attr('href', u );
}
else {
$('.error').show().delay(1000).queue(function(n) {
$('.error').hide(); n();
});
}
}
@charset "UTF-8";
/* CSS Document */

/*basic reset*/
/*browsers have built in values for elements so we'll reset a few things to zero, you can add to this or remove items as needed*/

div,p,body,header,footer,section,article,nav
{
margin: 0;
padding: 0;
}

img
{
border: none;
margin: 0;
padding: 0;
}

/* html selectors */

body
{
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
font-size: 12px;
color: #333;
background-color: #1d1d1d;
}


a:link, a:visited
{
text-decoration:none;
}

a:hover, a:active
{
text-decoration:none;
}

/* hide elements from browser but show for doc outline */

.hidden
{
display: none;
}

*
{
box-sizing: border-box;
margin: 0;
padding: 0;
}

body
{
background-color: #1d1d1d;
}

::selection
{
background-color: transparent;
}

.screen{
height: 75px;
width: 225px;
border-radius: 15px;
border: 8px solid #2b2b2b;
background-color: #111;
font-size: 50px;
color: limegreen;
padding: 0px 20px 0px 20px;
letter-spacing: 26px;
font-family: 'VT323', monospace;
position: relative;
}

.flasher {
content: "";
display: block;
width: 30px;
height: 5px;
background-color: limegreen;
position: absolute;
top: 55px;
left: 20px;
animation: blink 1s linear infinite;
-webkit-animation: blink 1s linear infinite;
}

.keypad_wrapper {
position: relative;
width: 225px;
height: 375px;
background-color: #2b2b2b;
margin: 100px auto;
}

.key {
width: 75px;
height: 75px;
float: left;
border-radius: 15px;
border: 8px solid #2b2b2b;
line-height: 58px;
text-align: center;
font-size: 50px;
background-color: #3b3b3b;
box-shadow: inset 0px -2px 0px rgba(0,0,0,.5), inset 0px 1px 0px rgba(255,255,255,.2);
cursor: pointer;
text-shadow: 0px -2px 2px rgba(0,0,0,.5), 0px 1px 2px rgba(255,255,255,.4);
color: #eee;
}

.key:hover {
background-color: #4b4b4b;
}

.key:active {
background-color: #333;
box-shadow: inset 0px -1px 0px rgba(255,255,255,.2), inset 0px 2px 0px rgba(0,0,0,.5);
color: #aaa;
line-height: 62px;
}

.key.last {
position: relative;
left: 75px;
}

.notification {
color: limegreen;
font-family: 'VT323', monospace;
text-align: center;
font-size: 40px;
position: absolute;
width: 225px;
top: 15px;
display: none;
}


@keyframes blink {
0%{opacity: 0;}
50%{opacity: 1;}
100%{opacity: 0;}
}

@-webkit-keyframes blink {
0%{opacity: 0;}
50%{opacity: 1;}
100%{opacity: 0;}
}
<!doctype html>
<html lang="en">

<head>
<meta charset="UTF-8">

<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.11.3.min.js"></script>
<script src="main.js"></script>

</head>



<div class="keypad_wrapper">
<div class="screen"></div>
<div class="flasher"></div>
<div class="error notification">ERROR</div>
<div class="success notification">SUCCESS</div>

<div class="key">1</div>
<div class="key">2</div>
<div class="key">3</div>
<div class="key">4</div>
<div class="key">5</div>
<div class="key">6</div>
<div class="key">7</div>
<div class="key">8</div>
<div class="key">9</div>
<div class="key last">0</div>
</div>



</body>
</html>

最佳答案

在我的浏览器中工作,我添加到您的代码中的所有内容是:

<link rel="stylesheet" type="text/css" href="style.css" />

但从你的问题来看,我认为你已经可以正常工作了。您可以尝试将 jquery 下载到本地计算机并在本地引用它。也许它会卡在那里。

关于javascript - 我似乎无法链接到我的 .js 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34424699/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com