按下按钮更改元素? [英] Change elements upon button press?

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

问题描述

我正在开始使用HTML和PHP。做得很好,我理解语法和一切。但是......我知道的仅仅是如何构建可能与我网站中的其他.php文件交互的页面元素。但是如果我想与同一页面中的其他元素进行交互呢?



这就是我想要实现的:
我得到了一些文本和一个按钮。我想按下按钮,这会使我的文本成为一个我可以编辑的文本框,然后再次按下按钮将文本框转换回纯文本。



<这是我不太明白的:与其他元素交互以改变它们的属性/值,似乎只是一些文档,或者我正在寻找错误的地方。如果是这样的话,有人可以指点我正确的学习来源吗?



谢谢。

解决方案

您需要javascript才能达到这个效果....网上和其他地方都有大量的例子: b
$ b

http://www.w3schools.com/js/tryit.asp?filename=tryjs_dom


I am getting started with HTML and PHP. Doing alright, I understand the syntax and everything. But... what I know is simply how to build page elements that may interact with other .php files in my site. But what if I want to interact with other elements in the same page?

This is what I'm trying to achieve: I got some text and a button. I want to press the button, and that will cause my text to become a textbox which I can edit, and afterwards press the button again to convert the textbox back to plain text.

That is what I don't quite get: interacting with other elements to change their attributes/values, seems to be little documentation about that, or I am looking in the wrong place. If that is the case, can someone point me to the correct learning source?

Thanks.

解决方案

You need javascript for that.... There are loads of examples online and everywhere:

http://www.w3schools.com/js/tryit.asp?filename=tryjs_dom

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

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