gpt4 book ai didi

php - 使用 jquery 从显示页面上的 php 输出中获取信息

转载 作者:行者123 更新时间:2023-11-30 23:18:01 25 4
gpt4 key购买 nike

好吧,基本上我有一个 php 页面,我们将调用 form.php。此页面包含一个带有日期选择器、时间选择器和文本框的表单(input type="date"input type="time"input type="textarea")。当用户提交表单时,信息被发送到mysql数据库,并在下一页“display.php”中输出。

所有这些都工作得很好。 display.php 页面由 form.php 中的代码构成IE。 <h1>This is the header</h1>
<h2 class="date">$date</h2>
<h3 class="time">$time</h3>
<p class="message">$message</p>

display.php 中的输出是


这是一个标题
2012-04-23
00:59
我的留言
一个按钮(只是为了检查我当前的工作)


我正在尝试像这样使用 jquery

$(document).ready(function(){ 
$('button').mousedown(function(){

if ($('h3').text() == "00:59") {
alert("Yup"); return true;}
else { alert("Nope");return false;};
});
});

这将无法匹配时间、日期或消息。如果我运行完全相同的代码但搜索不是使用变量创建的 h1,那将起作用。

 $(document).ready(function(){ 
$('button').mousedown(function(){

if ($('h1').text() == "This is a header") {
alert("Yup"); return true;}
else { alert("Nope");return false;};
});
});

我不知道我在这里错过了什么。

我什至可以将 h1 更改为 00:59,运行 jquery 搜索 h1 == "00:59",它会返回 true 并通过警报。

当我追踪从 php 变量($time、$date、$message)创建的 h2、h3 和 p 元素时

如有任何帮助,我们将不胜感激。

最佳答案

尝试关闭<p>元素正确:

<h1>This is the header</h1>
<h2 class="date">$date</h2>
<h3 class="time">$time</h3>
<p class="message">$message</p>

关于php - 使用 jquery 从显示页面上的 php 输出中获取信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16728790/

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