[英]Change a HTML page's content based on the value of a button?
I am creating an EDM music directory web-sight and I am having issues with the content. 我正在创建网络上的EDM音乐目录,但内容有问题。
There are tons of genres and sub-genres of EDM and I don't want to create a new page for each one (if possible) EDM有很多类型和子类型,我不想为每个页面创建一个新页面(如果可能)
Is there a way to switch the content of an HTML web-sight based on the value of a button? 有没有一种方法可以基于按钮的值来切换HTML Web-sight的内容? In other words, I want a HTML template with all the styling for the genre.
换句话说,我想要一个具有所有风格的HTML模板。 But I want to change the text, images and audio that goes into it.
但是我想更改其中的文本,图像和音频。
是的,可以确保在渲染时可以向按钮添加类或id,然后只需为单击操作添加事件侦听器即可。在侦听器中,您可以运行this.innerText以访问按钮文本。完成所有处理后,您可以按窗口获取整个文档HTML。 document.body.innerHTML并通过为body的此属性分配值来设置,我建议您宁可使用元素的类或id来更改它们,也可以运行element.childNodes [index]来更改网页上的元素
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.