gpt4 book ai didi

javascript - 我如何编写一个 onblur 函数来杀死这个 anchor 标记?

转载 作者:行者123 更新时间:2023-11-30 13:37:05 24 4
gpt4 key购买 nike

我为 508 合规性编写了这段代码,但在用户关闭它后,我希望该元素能够正常运行,我该如何做到这一点?以下是:

handleInteraction:function(focusable){
this.setElements();
var totalAllowed = (this.elements.totalChar[0].innerHTML);
var value = this.obj.value;
var chars = value.length;
var charsLeft = parseInt(totalAllowed) - parseInt(chars);
if (charsLeft >= 0 || (typeof focusable=='boolean' && focusable==false)){
this.elements.leftChar[0].innerHTML = charsLeft;
this.elements.charLeftp.removeClass("error");
}
else {
this.obj.value = value.substring(0, totalAllowed);
this.elements.leftChar[0].innerHTML = 0;
this.elements.charLeftp.addClass("error")
var divNA = dojo.byId("max-"+this.obj.id);
if (divNA){
dojo.destroy(divNA);
}
divNA = dojo.create("a",{"id":"max-"+this.obj.id,"class":"hide-fromsighted","innerHTML":"<h5>This textarea has reached the maximum allowed number of characters. Please navigate backwards!</h5>","tabindex":"-1"});
dojo.place(divNA,this.obj,'after');
divNA.focus();


/*
* Here apply the onblur event to kill the <a>
*/
}

最佳答案

我假设您正在使用 Dojo 工具包。你可以销毁 <a>用 dojo.destroy 标记,你可以使用 dojo.stopEvent 来停止 <a>事件传播。

http://www.dojotoolkit.org/reference-guide/dojo/destroy.html#dojo-destroy

http://www.dojotoolkit.org/reference-guide/dojo/stopEvent.html#dojo-stopevent

关于javascript - 我如何编写一个 onblur 函数来杀死这个 anchor 标记?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4402573/

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