动态删除HTML onClick

huangapple go评论79阅读模式
英文:

Go Dynamically Removing HTML onClick

问题

我是新手学习Go语言。我越来越理解基础知识,但现在我正在尝试学习如何将代码与HTML界面进行交互。

我的简单场景是,我有一个单个网页,其中的列表是由Go从数据库中获取信息,然后使用一组模板构建HTML页面。我只想创建一个简单的列表,当点击<div>时或其他操作时,可以将其标记为完成/已完成。此外,我还想能够完全删除网页列表中的一个"行",也就是一个div。

因此,我的列表将指示某些内容已完成(我认为我必须使用Go来修改CSS),并且可以删除一个项目(完全删除该HTML块)。请记住,这些项目存储在数据库中,因此我必须能够识别特定的项目。

非常感谢任何帮助、想法、资源、伪代码和指针!

英文:

I'm new to Go. I'm understanding the basics more and more but now I'm trying to learn how to interface the code with HTML.

My simple scenario is that I have a single web page with a list that's created by Go fetching information from a database, then building the html page from a group of templates. All I want is to make a simple list that will allow me to somehow mark it as complete/done when the &lt;div&gt; is clicked or something. Also, to be able to fully delete a "row" in my webpage list, a div basically.

So my list will indicate something is complete (I assume I must use Go to alter the css) and delete an item (completely remove that block of html). And remember, these items are stored in a database, so I must be able to identify the specific item.

Any help, ideas, resources, pseudocode, pointers would be greatly appreciated!

答案1

得分: 1

在Web开发中,有两个“端口”执行代码:浏览器和服务器,也就是前端和后端。

“点击”事件发生在浏览器中,并且会在浏览器中执行代码。这个“浏览器代码”可能会与服务器联系以获取额外的信息,然后将该信息呈现给浏览器。

这意味着服务器无法控制浏览器中发生的事情*,反之亦然。这是Web开发的基础知识。

Go是一种适用于构建服务器的语言。JavaScript是大多数浏览器理解的语言。你需要的是JavaScript,而不是Go。

*这并不完全准确,但足够作为学习的基础。

英文:

In web development, there are two "ends" where code executes; the browser and the server, aka. the front-end and the back-end.

A "click" happens in the browser and will execute code in the browser. That "browser-code" in turn may or may not contact the server for additional information and then render that information to the browser.

That means; the server has no control over what happens in the browser* and vice versa. That's the basics of web development.

Go is a language good for building servers. Javacript is the language that most browsers understand. What you need is Javascript, not Go.

* <sub>this is not entirely true but good enough as a base to start learning.</sub>

huangapple
  • 本文由 发表于 2014年9月25日 12:59:38
  • 转载请务必保留本文链接:https://go.coder-hub.com/26030850.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定