gpt4 book ai didi

javascript - 如何从
转载 作者:行者123 更新时间:2023-12-02 07:39:32 25 4
gpt4 key购买 nike

我想在流程进入 <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/

25 4 0

Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com