2015-10-12 46 views
0

当我点击输入你的名字时,什么都没有弹出在div标签中。我的目标是尝试使名称出现在具有不同ID的所有span标签中。但它甚至不会出现在一个。我也使用纯粹的JavaScript不知道为什么名称不显示在div

<!DOCTYPE html> 
<html> 
<head> 
    <meta charset="utf-8"> 
    <link rel="stylesheet" type="text/css" href="DreStone.css"> 
<title> o </title> 
<style> 

</style> 

     <!-- JAVASCRIPT --> 
    <script src="util.js"></script> 

<script> 
/********************** 
LOCAL NAMESPACE OBJECT 
***********************/ 
var z={}; 


/********************** 
EVENT HANDLERS 
***********************/ 
z.showName = function() 
    { var age = u.eid("names").value, 
    u.eid("firstname").innerHTML = "" + age; 

} 

/********************** 
WINDOW.ONLOAD 
***********************/ 
window.onload = function() 
{ 
u.eid("nameinput").addEventListener('click', z.showName); 
} 

</script> 

</head> 

<body> 

Please enter your name: <input id="names" type="text"> 

<button id="nameinput" type="button">Click after you enter your name</button> 

<p> 
How is your day going <span id="firstnam"> </span> 
    </p> 
<div>  I would like to you to take a look at this payment plan <span id="secondname"> </span>. 
It may prove to be very valueable to you. If you do not care then ignore this. Thank you <span id="thirdname"> </span> 
</div> 
<div id="firstname"> 
</div> 
</body> 
</html> 

任何帮助都是非常有用的。谢谢

+0

你确定u.eid的作品? – user2182349

+0

为什么不让JavaScript为您生成网页? –

+0

是的,我已经写了它的分区和u.eid工程,我甚至用document.getElementById替换它们,但仍然没有。 – erdenots

回答

0

如何将其更改为替换功能?喜欢的东西:

document.body.innerHTML = document.body.innerHTML.replace("How is your day going", "How is your day going " + document.form[0].user.value] + "?"); 
0

假设u.eid()是util.js中内的作品,你有()instaed的(;)

/********************** 
EVENT HANDLERS 
***********************/ 
z.showName = function() 
    { var age = u.eid("names").value; 
    u.eid("firstname").innerHTML = "" + age; 

} 
0

试试这个:

<!DOCTYPE html> 
<html> 
<head> 
    <meta charset="utf-8"> 
<title> o </title> 
<style> 

</style> 

<script> 
/********************** 
LOCAL NAMESPACE OBJECT 
***********************/ 
var z={}; 


/********************** 
EVENT HANDLERS 
***********************/ 
z.showName = function() 
    { var age = document.getElementById("names").value; 
    document.getElementById("firstname").innerHTML = "" + age; 

} 

/********************** 
WINDOW.ONLOAD 
***********************/ 
window.onload = function() 
{ 
document.getElementById("nameinput").addEventListener('click', z.showName); 
} 


</script> 

</head> 

<body> 

Please enter your name: <input id="names" type="text"> 

<button id="nameinput" type="button">Click after you enter your name</button> 

<p> 
How is your day going <span id="firstnam"> </span> 
    </p> 
<div>  I would like to you to take a look at this payment plan <span id="secondname"> </span>. 
It may prove to be very valueable to you. If you do not care then ignore this. Thank you <span id="thirdname"> </span> 
</div> 
<div id="firstname"> 
</div> 
</body> 
</html> 

这对我有用

相关问题