promt在JQuery中不起作用
我试图得到一个提示信息。但它不起作用promt在JQuery中不起作用,jquery,Jquery,我试图得到一个提示信息。但它不起作用 <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm10.aspx.cs" Inherits="WebApplication9.WebForm10" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> &l
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm10.aspx.cs" Inherits="WebApplication9.WebForm10" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h1 id="main-heading">Hello world!</h1>
<script>
$(document).ready(function () {
var headingElement = $("#main-heading");
console.log(headingElement.innerHTML);
var newHeadingText = prompt("Please provide a new heading:");
headingElement.innerHTML = newHeadingText;
});
</script>
</div>
</form>
</body>
</html>
你好,世界!
$(文档).ready(函数(){
var headingElement=$(“主标题”);
log(headingElement.innerHTML);
var newHeadingText=prompt(“请提供新标题:”);
headingElement.innerHTML=newHeadingText;
});
这就是Jquery方式。但不会显示提示
如何更改此选项,以显示提示
多谢各位
但是你说:
在标记之前,如下所示:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm10.aspx.cs" Inherits="WebApplication9.WebForm10" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h1 id="main-heading">Hello world!</h1>
</div>
</form>
<script>
$(document).ready(function () {
var headingElement = $("#main-heading");
console.log(headingElement.text);
var newHeadingText = prompt("Please provide a new heading:");
headingElement.innerHTML = newHeadingText;
});
</script>
</body>
</html>
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm10.aspx.cs" Inherits="WebApplication9.WebForm10" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h1 id="main-heading">Hello world!</h1>
</div>
</form>
<script>
$(document).ready(function () {
var headingElement = $("#main-heading");
console.log(headingElement.text());
var newHeadingText = prompt("Please provide a new heading:");
headingElement.text(newHeadingText);
});
</script>
</body>
</html>
你好,世界!
$(文档).ready(函数(){
var headingElement=$(“主标题”);
console.log(headingElement.text);
var newHeadingText=prompt(“请提供新标题:”);
headingElement.innerHTML=newHeadingText;
});
但这不起作用
好吧,我现在有了这样的:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm10.aspx.cs" Inherits="WebApplication9.WebForm10" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h1 id="main-heading">Hello world!</h1>
</div>
</form>
<script>
$(document).ready(function () {
var headingElement = $("#main-heading");
console.log(headingElement.text);
var newHeadingText = prompt("Please provide a new heading:");
headingElement.innerHTML = newHeadingText;
});
</script>
</body>
</html>
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm10.aspx.cs" Inherits="WebApplication9.WebForm10" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h1 id="main-heading">Hello world!</h1>
</div>
</form>
<script>
$(document).ready(function () {
var headingElement = $("#main-heading");
console.log(headingElement.text());
var newHeadingText = prompt("Please provide a new heading:");
headingElement.text(newHeadingText);
});
</script>
</body>
</html>
你好,世界!
$(文档).ready(函数(){
var headingElement=$(“主标题”);
log(headingElement.text());
var newHeadingText=prompt(“请提供新标题:”);
headingElement.text(newHeadingText);
});
但是现在仍然显示提示。应该在正文结束标记
之前添加脚本
$(文档).ready(函数(){
var headingElement=$(“主标题”);
log(headingElement.text());
var newHeadingText=prompt(“请提供新标题:”);
headingElement.text(newHeadingText);
});代码>
你好,世界!
脚本应添加到正文结束标记之前,
$(文档).ready(函数(){
var headingElement=$(“主标题”);
log(headingElement.text());
var newHeadingText=prompt(“请提供新标题:”);
headingElement.text(newHeadingText);
});代码>
你好,世界!
ah。非常感谢。Nice@LikeToDo您是否阅读了上面回答中有关text
方法和innerHTML
属性的注释?如我所见,您仍在使用innerHTML
@liketo,您有什么错误吗?打开开发者工具,按F12键(如果使用Chrome),然后进入名为Console的选项卡,就可以很容易地发现这一点。你看到什么留言了吗?您确定已加载jquery库吗?再次阅读您的代码,我几乎可以肯定您忘记添加jquery库了。应在加载您的纸条之前请求此库。因此,在开始脚本标记之前,
,您应该有这样的
@LikeToDo Great!啊。非常感谢。Nice@LikeToDo您是否阅读了上面回答中有关text
方法和innerHTML
属性的注释?如我所见,您仍在使用innerHTML
@liketo,您有什么错误吗?打开开发者工具,按F12键(如果使用Chrome),然后进入名为Console的选项卡,就可以很容易地发现这一点。你看到什么留言了吗?您确定已加载jquery库吗?再次阅读您的代码,我几乎可以肯定您忘记添加jquery库了。应在加载您的纸条之前请求此库。因此,在开始脚本标记之前,
,您应该有这样的
@LikeToDo Great<代码>提示符()
不是jQuery。。。。只是说..那怎么纠正呢?谢谢Christos已经回答:)prompt()
不是jQuery。。。。只是说..那怎么纠正呢?谢谢,克里斯托斯已经回答:)