0

更新 0

收到此错误消息:未捕获的 ReferenceError:$ 未定义

更新 0

更新 1 个最新源

<html>
  <head>
      <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
      <title>Reservations</title>
    <link rel="stylesheet" href="/static/css/main.css">
    <link rel="stylesheet" href="/static/css/style.css">
  </head>
  <body>
      <center><h1>Reservations</h1></center>
    <div class="wrapper">

<p> You can start over at the beginning <a href="/">here.</a> </p>
<big>Reserve some courts online  </big> <br />
<script type="text/javascript" language="JavaScript">
    $( document ).keypress(function() {
    $("#timeStamp span").text("Timestamp is no-longer correct");
});
</script>
<form action="" method="post" >
       <input type="hidden" name="ID" value="Rogers"></input>
       <input type="hidden" name="weekday" value="Tuesday"></input>
       <input type="hidden" name="nowweekday" value="1"></input>
       <input type="hidden" name="month" value="September"></input>
       <input type="hidden" name="nowmonth" value="9"></input>
       <input type="hidden" name="day" value="18"></input>
       <input type="hidden" name="year" value="2012"></input>
       <input type="hidden" name="startTime" value="[15, 0]"></input>
       <input type="hidden" name="endTime" value="[20L, 0L]"></input>

       <input type="hidden" name="court" value="court1"></input>

       <input type="hidden" name="court" value="court2"></input>

       <h1>Tuesday, September 18, 2012 at Rogers Neighborhood Club</h1> 
   <div class="timeStamp" ><h1 id="timeStamp">15:07:24.657430<span></span></h1></div> <br />

更新 1 个最新源

我在页面加载时创建的页面上有一个时间戳。

我想更改时间戳的相邻文本标签,以表明keyDownwindow.

可以用javascript轻松完成吗?

<html>
  <head>
      <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
      <title>Reservations</title>
    <link rel="stylesheet" href="/static/css/main.css">
    <link rel="stylesheet" href="/static/css/style.css">
  </head>
  <body>
      <center><h1>Reservations</h1></center>
    <div class="wrapper">

<p> You can start over at the beginning <a href="/">here.</a> </p>
<big>Reserve some courts online  </big> <br />
<script type="text/javascript" language="JavaScript">
    $("*").keypress(function() {
    $("#timeStamp").text("Modified");
    });
</script>

<form action="" method="post" >
       <input type="hidden" name="ID" value="Rogers"></input>
       <input type="hidden" name="weekday" value="Tuesday"></input>
       <input type="hidden" name="nowweekday" value="1"></input>
       <input type="hidden" name="month" value="September"></input>
       <input type="hidden" name="nowmonth" value="9"></input>
       <input type="hidden" name="day" value="18"></input>
       <input type="hidden" name="year" value="2012"></input>
       <input type="hidden" name="startTime" value="[14, 30]"></input>
       <input type="hidden" name="endTime" value="[20L, 0L]"></input>

       <input type="hidden" name="court" value="court1"></input>

       <input type="hidden" name="court" value="court2"></input>

       <h1>Tuesday, September 18, 2012 at Rogers Neighborhood Club</h1> 
   <div class="timeStamp" id="timeStamp"><h1>text14:49:30.274646</h1></div> <br />
4

2 回答 2

1

是的,就像这样:

假设您使用的是 jQuery 并且有这样的时间戳 HTML:

<p id="timeStamp">2012-09-18 20:08 <span></span></p>
<!-- the span is where the message will be inserted -->

...以及 jQuery 代码本身:

$( document ).keypress(function() {
    $("#timeStamp span").text("Timestamp is no-longer correct");
});
于 2012-09-18T19:02:15.320 回答
0

像这样改变你的身体元素:<body onload="document.body.focus()" onkeyup="key()">......每次按下键时它都会执行键功能。在那里做你想做的一切..

于 2012-09-18T19:08:47.523 回答