網站首頁 編程語言 正文
Uncaught RangeError: Maximum call stack size exceeded問題解決
html:
<div id="item_fx" size="0,180,100%,15,BP1">
<div id="fx_wtxx">
<input id="fx_check" type="checkbox" ></input>
<label id="fx_name1" for="fx_check" text="腹瀉"></label>
<label id="fx_name3" text="次/天" ></label>
<input id="fx_input" disabled placeholder="" maxlength="100" border-radius="5"></input>
</div>
</div>
js:
$('#fx_wtxx').click(function() {
var fx_check = document.getElementById('fx_check');
if(fx_check.checked){
$('#fx_input').removeAttr("disabled");
$('#fx_input').focus();
$('#fx_input').click();
}else {
$('#fx_input').attr("disabled",'true');
$('#fx_input').blur();
}
});
點擊#fx_wtxx時,觸發#fx_input,結果代碼報錯:Maximum call stack size exceeded。
報錯原因:出現無限循環。
代碼實現的是點擊div時觸發input的點擊事件,但是這個input是被包裹在div內部的,所以input的點擊事件觸發后,通過事件冒泡又觸發了div的點擊事件,div的點擊事件又去觸發input的點擊事件,input的點擊事件再次冒泡觸發div的點擊事件……如此一來便造成了無限循環,所以報錯:Maximum call stack size exceeded。
解決方法:將input移出div即可。
原文鏈接:https://blog.csdn.net/lyc___/article/details/121417622
相關推薦
- 2022-10-31 C#?如何調用python腳本_C#教程
- 2022-03-14 sql 排序order by重復數據問題
- 2022-06-12 批處理命令call、start、goto的使用_DOS/BAT
- 2022-04-24 C#中的==運算符用法講解_C#教程
- 2022-09-04 Go語言異常處理(Panic和recovering)用法詳解_Golang
- 2023-01-28 ajax、axios和fetch之間優缺點重點對比總結_AJAX相關
- 2023-04-01 Python實現處理apiDoc轉swagger的方法詳解_python
- 2022-08-06 Android?無障礙全局懸浮窗實現示例_Android
- 最近更新
-
- window11 系統安裝 yarn
- 超詳細win安裝深度學習環境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區別,Jav
- spring @retryable不生效的一種
- Spring Security之認證信息的處理
- Spring Security之認證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權
- redisson分布式鎖中waittime的設
- maven:解決release錯誤:Artif
- restTemplate使用總結
- Spring Security之安全異常處理
- MybatisPlus優雅實現加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務發現-Nac
- Spring Security之基于HttpR
- Redis 底層數據結構-簡單動態字符串(SD
- arthas操作spring被代理目標對象命令
- Spring中的單例模式應用詳解
- 聊聊消息隊列,發送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠程分支