javascript - 未捕获的 ReferenceError:我的函数未在 HTMLInputElement.onclick 中定义
问题描述
当我在 Wordpress rawhtml 代码中插入此代码时,我在页面视图中出现此错误,您能帮我解决为什么会出现此错误吗?未捕获的 ReferenceError:我的函数未在 HTMLInputElement.onclick 中定义
这是代码片段:
function myfunction(id)
{
if(id>4)
{
document.getElementById('msg2').style.display="block";
document.getElementById('msg1').style.display="none";
document.getElementById('url2').style.display="block";
document.getElementById('url1').style.display="none";
}
else
{
document.getElementById('msg2').style.display="none";
document.getElementById('msg1').style.display="block";
document.getElementById('url1').style.display="block";
document.getElementById('url2').style.display="none";
}
}
<div class="cont">
<div class="stars">
<form action="">
<input class="star star-5" id="star-5" type="radio" name="star" onclick="return myfunction(5)"/>
<label class="star star-5" for="star-5"></label>
<input class="star star-4" id="star-4" type="radio" name="star" onclick="myfunction(4)"/>
<label class="star star-4" for="star-4"></label>
<input class="star star-3" id="star-3" type="radio" name="star" onclick="myfunction(3)"/>
<label class="star star-3" for="star-3"></label>
<input class="star star-2" id="star-2" type="radio" name="star" onclick="myfunction(2)"/>
<label class="star star-2" for="star-2"></label>
<input class="star star-1" id="star-1" type="radio" name="star" onclick="myfunction(1)"/>
<label class="star star-1" for="star-1"></label>
</form>
</div>
<br>
<br>
<h3 id="msg1" style="display:none;">Give us a feedback</h3>
<h3 id="msg2" style="display:none;">Thank you! We'd be grateful if you could give us a short review</h3>
<br>
<a class="click_here" id="url1" href="#" style="display:none;">SUBMIT</a>
<a class="click_here" id="url2" href="#" style="display:none;">SUBMIT</a>
</div>
解决方案
推荐阅读
- flutter - 颤振滑块值未在 getx 对话框中更新
- javascript - 如何在默认浏览器 React Native 中注入 javascript?
- igor - Igor Pro,如何将波形中的一个文本值转换为字符串
- c++ - 假设只初始化静态成员,隐式默认构造函数是否仍然微不足道?
- reactjs - 导入 SVG 与需要 SVG
- php - laravel 调度运行什么也不做
- javascript - 从类的构造函数中将方法设置为按钮的 onclick 操作
- python - 如果未在规定时间内指定输入,则终止 Python 程序
- r - 为什么当我执行 write.csv 时,我没有得到与全局环境中显示的完全相同的数据帧输出
- r - 向箱形图添加点