gpt4 book ai didi

javascript - 我的 jQuery 无法处理特定的事情

转载 作者:太空宇宙 更新时间:2023-11-03 21:03:10 25 4
gpt4 key购买 nike

我写了一些 jQuery,但我写的似乎没有任何效果。我已经通过执行 $(document).ready(function(){ alert("jQuery is working !"); }); 测试了 jQuery 以检查其是否正常工作。它确实发送了警报。

我尝试重新链接 jQuery 并检查了我的 <head>标记了数百万次,我的眼睛找不到任何错误。

<!DOCTYPE html>
<html>

<head>
<title>Abdalla Abouzeid</title>
<script src="jquery-ui.min.js"></script>
<script src="jquery-3.4.1.min.js"></script>
<script src="javascript.js"></script>
<meta name="description" content="This is my portoflio">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta property="og:site_name" content="www.anzads.com" />
<meta property="og:type" content="Portoflio" />
<meta property="og:image" content="413976bd.jpg">
<link href="https://fonts.googleapis.com/css?family=Yanone+Kaffeesatz&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Poiret+One&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Sacramento&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://use.typekit.net/zyl3kwb.css">
<link rel="stylesheet" type="text/css" href="style.css">
<link rel="stylesheet" type="text/css" href="jquery-ui.min.css">
<link rel="stylesheet" type="text/css" href="jquery-ui.structure.min.css">
<link rel="stylesheet" type="text/css" href="jquery-ui.theme.min.css">
</head>

<body>
<!--This is the header {logo , menu}-->
<div id="container">
<div id="header">
<div class="logo">
<a href="default.html">
<p>
A n Z
</p>
</a>
</div>

<ul class="menu">


<a href="default.html">
<li>Home</li>
</a>
<a class="links" href="Contact.html">
<li>Contact</li>
</a>


<a class="links" href="Projects.html">
<li>Projects</li>
</a>
</ul>



</div>


<div class="content">
<hr>

<h1>
Are you trying to build a professional website ?
</h1>

<P>
Hello , i am a web designer / front end developer. Bringing your vision alive is pivotal to me and that is what sets me apart. Let's create a professional yet astonishing desgins for our website that shows your vision.
</P>


<hr>

<h2>My Services</h2>
<hr class="titleUnderline">
<div class="services , separation">

<div class="leftBox , serviceBox">
<img class="serviceLogo" src="web-design.svg">
<h3> Web Design <br/> <span class="subTitle">UI Focused</span></h3>

<p>
Designing a website must be specific to its activity. This is what i do , designing a website professionally to deliver its purpose to the users of the website. User focused website should be the primary goal of any website.
</p>
</div>

<div class="rightBox , serviceBox">
<img class="serviceLogo" src="responsive-design-symbol.svg">
<h3> Web Development <br/> <span class="subTitle">Responsive and Fast</span></h4>
<p>
Every Website must have to goals to achieve . First it must be resposive which means for it to work on all devices . Second it has to to load as fast as possible to guarantee a very good user experiece.
</p>
</div>
</div>
<div class="services , separation">
<div class="leftBox , serviceBox">
<img class="serviceLogo" src="G designing.svg">
<h3>Logo Designing <br/> <span class="subTitle">Iconic Styles</span></h3>
<p>
A website's logo describes their product , targets audience and industry . It commonly outlines fundamental information about the business, the desired design , the project timing and the budget.
</div>

<div class="rightBox , serviceBox">
<img class="serviceLogo" src="htmlcss.svg">
<h3>Front-End Development <br/> <span class="subTitle">HTML / CSS</span></h3>
<p>
Creating a strong foundation for a website means getting the HTML and CSS architecture right. If you've got a design I can create the front-end code for it.
</p>

</div>
</div>
</div>
<br/>
<hr>
<div id="footer">
<div class="copyright">
<p>
&copy;Copyright 2019 AnZ <sup>&reg;</sup>
</p>


<a href="https://www.instagram.com/abuzied365/?hl=en" target="_blank">
<img src="instagram.svg"></a>
<a href="https://www.facebook.com/AbuziedAbdalla" target="_blank">
<img src="facebook.svg">
</a>
<a href="https://twitter.com/AbuzeidAbdalla" target="_blank">
<img src="twitter.svg">
</a>
</div>
</div>

</div>
</div>

</body>

</html>
        body {
width: 100%;
margin: auto;
color: #7D7B7B;
}

#header {
font-family: 'Yanone Kaffeesatz', sans-serif;
height: 15%;
position: relative;
top: 10px;
text-align: center;
}

h2,
h3,
h4,
h5,
h5 {
font-family: 'Yanone Kaffeesatz', sans-serif;
}

h1 {
font-family: 'Yanone Kaffeesatz', sans-serif;
font-size: 45px;
}

p {
font-family: 'Poiret One', cursive;
font-size: 20px;
font-weight: 650;
}

a:link {
text-decoration: none;
}

a:active {
text-decoration: none;
}

a:hover {
text-decoration: none;
}

.logo p {
font-family: 'Sacramento', cursive;
font-size: 50px;
outline: 0;
text-rendering: optimizeLegibility;
color: #7D7B7B;
}

ul {
list-style-type: none;
}

#container {
width: 80%;
margin: auto;
}

hr {
border: 1px solid #7D7B7B;
margin-top: 15px;
margin-bottom: 15px;
}

.menu li {
display: inline;
font-size: 20px;
}

.links {
margin-left: 7%;
}

.menu {
padding: 4px;
}

.menu a {
color: #7D7B7B;
}

.leftBox {
width: 30%;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
margin-right: 10%;
margin-left: 5%;
text-align: center;
border-radius: 15px;
-webkit-border-radius: 15px;
-moz-border-radius: 15px;
-ms-border-radius: 15px;
-o-border-radius: 15px;
}

.rightBox {
width: 30%;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
margin-left: 10%;
text-align: center;
border-radius: 15px;
-webkit-border-radius: 15px;
-moz-border-radius: 15px;
-ms-border-radius: 15px;
-o-border-radius: 15px;
}

h2 {
font-size: 35px;
}

h3 {
font-size: 30px;
}

.services {
width: 100%;
display: flex;
flex-flow: row;
}

.services p,
h3 {
padding: 5px;
line-height: 35px;
}

.subTitle {
font-weight: 100;
font-size: 25px;
}

.titleUnderline {
width: 8%;
float: left;
margin-bottom: 25px;
}

.serviceLogo {
width: 150px;
height: 200px;
}

.separation {
margin-top: 100px;
}

.copyright {
text-align: center;
}

.copyright img {
width: 40px;
height: 40px;
margin-bottom: 50px;
}

.contactMe img {
width: 50px;
height: 50px;
float: left;
margin-right: 30px;
}

.underline {
width: 11%;
float: left;
}

.title {
margin-bottom: 100px;
}

.number,
.myEmail {
font-family: 'Gruppo', cursive;
font-weight: 600;
font-size: 26px;
}

.comingSoon {
font-size: 60px;
text-align: center;
}
/* @media only screen and (min-device-width: 320px) and (max-device-width: 480px) {
.leftBox,
.rightBox {
width: 80%;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
margin-right: 10%;
margin-left: 5%;
text-align: center;
border-radius: 15px;
-webkit-border-radius: 15px;
-moz-border-radius: 15px;
-ms-border-radius: 15px;
-o-border-radius: 15px;
}
}*/

$(".logo").click(function() {
$("body").css("background-color", "black");
});

这些是我页面上的所有代码。我认为这可能是一个链接问题,但我不知道它是否真的是。我检查了 visual studio 代码编辑器,看看是否有任何语法或语义错误,但它没有显示任何内容。

最佳答案

假设您只包含标准的 jQuery,您的 jQuery 将按预期工作;点击 .logo类更改了 <body>颜色到黑色:

$(".logo").click(function() {
$("body").css("background-color", "black");
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

<body>
<!--This is the header {logo , menu}-->
<div id="container">
<div id="header">
<div class="logo">
<a href="default.html">
<p>
A n Z
</p>
</a>
</div>

<ul class="menu">


<a href="default.html">
<li>Home</li>
</a>
<a class="links" href="Contact.html">
<li>Contact</li>
</a>


<a class="links" href="Projects.html">
<li>Projects</li>
</a>
</ul>



</div>


<div class="content">
<hr>

<h1>
Are you trying to build a professional website ?
</h1>

<P>
Hello , i am a web designer / front end developer. Bringing your vision alive is pivotal to me and that is what sets me apart. Let's create a professional yet astonishing desgins for our website that shows your vision.
</P>


<hr>

<h2>My Services</h2>
<hr class="titleUnderline">
<div class="services , separation">

<div class="leftBox , serviceBox">
<img class="serviceLogo" src="web-design.svg">
<h3> Web Design <br/> <span class="subTitle">UI Focused</span></h3>

<p>
Designing a website must be specific to its activity. This is what i do , designing a website professionally to deliver its purpose to the users of the website. User focused website should be the primary goal of any website.
</p>
</div>

<div class="rightBox , serviceBox">
<img class="serviceLogo" src="responsive-design-symbol.svg">
<h3> Web Development <br/> <span class="subTitle">Responsive and Fast</span></h4>
<p>
Every Website must have to goals to achieve . First it must be resposive which means for it to work on all devices . Second it has to to load as fast as possible to guarantee a very good user experiece.
</p>
</div>
</div>
<div class="services , separation">
<div class="leftBox , serviceBox">
<img class="serviceLogo" src="G designing.svg">
<h3>Logo Designing <br/> <span class="subTitle">Iconic Styles</span></h3>
<p>
A website's logo describes their product , targets audience and industry . It commonly outlines fundamental information about the business, the desired design , the project timing and the budget.
</div>

<div class="rightBox , serviceBox">
<img class="serviceLogo" src="htmlcss.svg">
<h3>Front-End Development <br/> <span class="subTitle">HTML / CSS</span></h3>
<p>
Creating a strong foundation for a website means getting the HTML and CSS architecture right. If you've got a design I can create the front-end code for it.
</p>

</div>
</div>
</div>
<br/>
<hr>
<div id="footer">
<div class="copyright">
<p>
&copy;Copyright 2019 AnZ <sup>&reg;</sup>
</p>


<a href="https://www.instagram.com/abuzied365/?hl=en" target="_blank">
<img src="instagram.svg"></a>
<a href="https://www.facebook.com/AbuziedAbdalla" target="_blank">
<img src="facebook.svg">
</a>
<a href="https://twitter.com/AbuzeidAbdalla" target="_blank">
<img src="twitter.svg">
</a>
</div>
</div>

</div>
</div>

</body>

你的.logo一文不值仅受到单个 <a> 的影响标签,然后单击此按钮将使您离开(可能在您看到颜色变化之前)。

问题本身几乎肯定在您的 <head> 中文件:您在 jQuery 本身之前引用 jQuery UI,然后似乎有第三个 JavaScript 文件:

<script src="jquery-ui.min.js"></script>
<script src="jquery-3.4.1.min.js"></script>
<script src="javascript.js"></script>

您需要在 jQueryUI 之前加载 jQuery,确保不会意外地包含 jQuery 两次,或使用任何声明 $ 的框架。本身:

<script src="jquery-3.4.1.min.js"></script>
<script src="jquery-ui.min.js"></script>
<script src="javascript.js"></script>

关于javascript - 我的 jQuery 无法处理特定的事情,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57487818/

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