English 中文(简体)
Javascript: 不会改变四舍五入的超文本
原标题:Javascript: Does not change the div innerHTML

我确实不能理解为什么不这样做。 我尝试了两条trick子,但我没有这样做。

<html>
<head>
<script type="text/javascript">
alert( Hey );
    var vText = document.getElementById("results");
        vText.innerHTML =  Changed ;
        alert(vText.innerHTML);
</script>
</head>
<body>
<div id="results">
hey there
</div>
</body>
</html>
最佳回答

你们可以在此看到:

http://jsfiddle.net/gHbs/

重要的是,你把 Java放在你的超声波集装箱之后。

问题回答

你再次面临的问题是,浏览器将 Java印成在翻版/处理页时所碰到的。 此时此刻,将alert(>>,但相关内容为#result<>/code>div。 当时,在人力部就没有存在,因此无法改变任何情况。

为解决这一问题,您可在网页尾贴上script, 即刻在</one> tag, 或将代码在onload上操作。 <代码>或<编码>>>。

文字必须放在干#后或卸载后,否则,在你试图取用时,该元素还未知。

You need to call this script in onload event i.e

 window.onload=function(){
//your code
}
<html>
<head>
<script type="text/javascript">
function onloadCall()
{
    alert( Hey );
    var vText = document.getElementById("results");                                                 
    vText.innerHTML =  Changed ;
    alert(vText.innerHTML);
}
</script>
</head>
<body onload="onloadCall()">
    <div id="results">
    hey there
    </div>
</body>
</html>

以上幻灯塔预示着你





相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签