如何使用jquery创建一个要求输入的弹出窗口

时间:2015-01-02 11:03:04

标签: javascript jquery html json ember.js

我的index.html代码是

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>Ember Starter Kit</title>
  <link rel="stylesheet" href="css/normalize.css">
  <link rel="stylesheet" href="css/style.css">
<link rel="stylesheet" href="css/one.css">
</head>
<body>

<!--Script1-->

  <script type="text/x-handlebars">
    <div id="W">
<h1> Welcome </h1>
</div>

<div id="section1">
<h2>   {{#link-to 'DINESH'}} DINESH {{/link-to}}  </h2>
</div>

<div id="section">
<h2> {{#link-to 'HOME'}} HOME {{/link-to}} </h2> 
</div>

<div id="section2">
<h2> {{#link-to 'CLICK'}} CLICK {{/link-to}} </h2> 
</div> 

 {{outlet}}

  </script>

  <!--Script2-->

  <script type="text/x-handlebars" id='HOME'>
  <div class-'HOME'>
  <p>
    This is a sample site for practicing Ember.js 
  </p>
  </script>

  <!--Script3-->

   <script type="text/x-handlebars" id='DINESH'>
  <div class-'DINESH'>
  <p>
     I welcome you to my page.. keep in touch......!!!!!
  </p>
  VIDIYAL
<br>

   Being the "Director of Community Service" in Rotaract Club of Future League, I organised a project called "VIDIYAL" where i taught basic computer knowledge to Orphanage Students. 
  </script>

  <!--Script4-->

  <script type="text/x-handlebars" id='CLICK'>

<div class-'CLICK'>
<p> Click the button to display the information which you want: </p>

<button onclick="myFunction()">Click me</button>

<p id="CLICK"></p>

<script>
function myFunction() {
    document.getElementById("demo").innerHTML = "Hello World";
}



  </script>


  <script src="js/libs/jquery-1.10.2.js"></script>
  <script src="js/libs/handlebars-v2.0.0.js"></script>
  <script src="js/libs/ember-1.9.1.js"></script>
  <script src="js/app.js"></script>
  <!-- to activate the test runner, add the "?test" query string parameter -->
  <script src="tests/runner.js"></script>
</body>
</html>

和app.js代码是

App = Ember.Application.create();

App.Router.map(function()
{
    this.resource('HOME');
    this.resource('DINESH');
    this.resource('CLICK');
});

如果我点击它会显示一个弹出窗口,询问我的姓名(&#34;输入你的姓名&#34;)。

我是一名非常擅长编程的学生。所以请尽可能简单地解释我。

2 个答案:

答案 0 :(得分:2)

您可以在纯JavaScript中执行此操作。 prompt()方法会为您执行此操作。 查看here

如果你想在Ember.js中这样做,你需要在用户点击时打开一个模态。 创建了一个小提琴http://jsfiddle.net/rocky_217/uxa38xjz/4/

答案 1 :(得分:1)

您可以在jquery或js中使用prompt()函数来接收弹出窗口中的输入。看看代码 - :

<script>

var childAge =  prompt("Enter Child  age")
alert(childAge);

</script>