改变文字 [英] changing text

查看:55
本文介绍了改变文字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是javascript的新手,但是慢慢变得越来越好


我想做的是在屏幕上显示一些文字,当事件发生时

例如点击一个按钮,文字会变成我想要的。


我该怎么做?

解决方案

< blockquote>你好Chris,


这是一些未经测试的代码。但它必须是这样的。


< html>

< body>

< script language =" ; JavaScript">

函数changeText(){

var element = document.getElementById(" myText");

element.innerHTML =" New Text";

}

< / script>


< div id =" myText" >第一个文字< / div>

< input type =" button" onclick =" changeText()">

< / body>

< / html>


- -


JP


chris schreef:

我是javascript的新手,但慢慢变好
<我想做的是在屏幕上显示一些文字,当事件发生时
例如点击一个按钮,文字就会变成我想要的。

我该怎么做这个??



是的,它给了我一些工作 - 谢谢


" JP" < jp@provider.net>在留言中写道

news:d5 ********** @ news4.zwoll1.ov.home.nl ...

嗨Chris,

这是一些未经测试的代码。但它必须是这样的。

< html>
< body>
< script language =" JavaScript">
function changeText( ){
var element = document.getElementById(" myText");
element.innerHTML =" New Text";
}
< / script>

< div id =" myText">第一个文字< / div>
< input type =" button" onclick =" changeText()">
< / body>
< / html>

-

JP
我是javascript的新手,但慢慢变好

我想要做的是屏幕上有一些文字,当一个事件<例如,单击按钮,文本将更改为我想要的内容。

我该怎么做?


< br>

chris写道:

我是javascript的新手,但慢慢变好

我想做的是在屏幕上显示一些文字当一个事件发生时
例如点击一个按钮,文本就会变成我想要的。

我该怎么办?




首先阅读这组FAQ,其URL在我的签名中。你

正在寻找DynWrite()。


然后你从你的记忆中删除不合适的alt.comp.lang.javascript。


-

兰迪

comp.lang.javascript常见问题 - http://jibbering.com/faq &新闻组周刊


im new to javascript but slowly getting better

what i want to do is have some text on the screen and when an event happens
for example click a button the text would change to what i want.

how would i do this ??

解决方案

Hi Chris,

Here is some untested code. But it must be something like this.

<html>
<body>
<script language="JavaScript">
function changeText() {
var element = document.getElementById("myText");
element.innerHTML = "New Text";
}
</script>

<div id="myText">First text</div>
<input type="button" onclick="changeText()">
</body>
</html>

--

J.P.

chris schreef:

im new to javascript but slowly getting better

what i want to do is have some text on the screen and when an event happens
for example click a button the text would change to what i want.

how would i do this ??



yep that gives me something to work with - thanks

"J.P." <jp@provider.net> wrote in message
news:d5**********@news4.zwoll1.ov.home.nl...

Hi Chris,

Here is some untested code. But it must be something like this.

<html>
<body>
<script language="JavaScript">
function changeText() {
var element = document.getElementById("myText");
element.innerHTML = "New Text";
}
</script>

<div id="myText">First text</div>
<input type="button" onclick="changeText()">
</body>
</html>

--

J.P.

chris schreef:

im new to javascript but slowly getting better

what i want to do is have some text on the screen and when an event
happens for example click a button the text would change to what i want.

how would i do this ??



chris wrote:

im new to javascript but slowly getting better

what i want to do is have some text on the screen and when an event happens
for example click a button the text would change to what i want.

how would i do this ??



You start by reading this groups FAQ, its URL is in my signature. You
are looking for DynWrite().

Then you drop the inappropriate alt.comp.lang.javascript from your memory.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly


这篇关于改变文字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆