作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想在流程进入 <c:if>
时调用一个 javascript 函数 block 。
例如,我有以下代码:
<c:if test="${!empty errorMessage && !(fn:contains(errorMessage, 'generic'))}">
<span> errorError occured<br />
</span>
</c:if>
只有当这个 <c:if>
时我才需要调用一个 JS 函数是真的。
请建议如何实现这一目标。
最佳答案
您可以包含 <script>
<c:if>
内的标签 block ,像这样:
<c:if test="${!empty errorMessage && !(fn:contains(errorMessage, 'generic'))}">
<span>
errorError occured<br />
</span>
<script>
alert("Calling my function ...");
myFunction(); // this is a call to your function which must be defined in the <head> section or another JS file.
</script>
</c:if>
希望这对您有所帮助。
关于javascript - 如何从 <c :if block 调用 javascript 函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12577482/
我是一名优秀的程序员,十分优秀!