gpt4 book ai didi

jquery - 如何使用 Jquery 在点击时将

添加到

转载 作者:行者123 更新时间:2023-11-28 16:00:28 25 4
gpt4 key购买 nike

我确定这是一个简单的问题。我是编码新手,只是学习 html/css/jquery 的基础知识。我正在尝试通过单击加载内容。这是我的代码,提前感谢您的耐心等待。

html:
<!DOCTYPE html>
<html>
<head>
<link type="text/javascript" src="wedding_projectJQuery.js"></link>
<link type="text/css" rel="stylesheet" href="wedding_projectStyles.css"/>
<title>Jason & Ashley Wedding</title>
</head>

<body>
<h1>Jason & Ashley's Wedding Website</h1>
<div id="loader"></div>
<table>
<tr>
<td id="date">Date</td>
<td id="photos">Photos</td>
<td id="donate">Donate</td>
</tr>

</table>
</body>

</html>

CSS:

h1 {
text-align:center;
}


#loader {
text-align:center;
border: 2px solid black;
margin:auto;
height: 500px;
width: 1000px;
}

table {
padding:0px;
border: 2px solid black;
width:1000px;
height:75px;
margin:2px auto;
clear:both;
}
td {
width:250px;
margin:0px;
padding:0px;
text-align:center;
border: 1px solid black;
padding:0px;
margin:0px;
}
td:hover {
background-color:green;
}

J查询:

$(document).ready(function(){
$("#date").click(function(){
$("#loader").prepend('<p>The date is October 25th, 2014. The ceremony will begin when the fat lady sings.</p>');

});

});

最佳答案

您需要在您的页面中包含 jQuery,它应该可以工作。

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script type="text/javascript" src="wedding_projectJQuery.js"></script>

另请注意,您需要使用 <script></script>而不是 <link />包含您的 Javascript 文件

Fiddle Demo

关于jquery - 如何使用 Jquery 在点击时将 <p> 添加到 <div>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23287700/

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