首页 > 解决方案 > 如何在 wordpress.com 网站中添加按钮和输入

问题描述

我在我的 wordpress.com 网站上添加了一个自定义 html 块,并编写了一些简单的代码来充当搜索小部件。

我已经尝试了很多东西。我尝试让按钮运行脚本函数,我尝试让函数监听按钮,我尝试使用 aa href 链接(如果我更努力的话,也许会起作用)。

<input type="text" id="input" value="Search...">
<br>
<button onclick="window.location.href = 'https://vinelings.home.blog/?s=' + document.getElementById('input').value"> Search</button>

我希望它使按钮抓取输入文本,然后将选项卡重定向到该术语的搜索。不确定这是否是 wordpress.com 的问题,如果是,我可以以任何方式解决它吗?

代码:https ://imgur.com/iRvb29V.jpg 结果:https ://imgur.com/GUcwIg9.jpg

编辑: 我正在使用该Custom HTML块。我的主题是 ALtoFocus。

标签: htmlwordpress

解决方案


在此处输入图像描述

您需要将您的 html 标记放入custom html块中


推荐阅读