小言_互联网的博客

event.stopPropagation(),阻止冒泡事件

399人阅读  评论(0)
{header:'${text("说明xxxx")}', name:'name1', editable:true, edittype:'textarea','onkeydown':'stopPropagation(event)'
editoptions:{'maxlength':'255', 'class':'form-control', 'rows':'2'}},
function stopPropagation(event) {
    var key = event.which;
    var where = event.target;
    var trNowWhere = $(where).parents('tr')
	//tr所在列索引
    var trIndex = trNowWhere.index();
	//与tr平级的总tr数量
    var trAllNums = trNowWhere.parent().children().length-1;
    if (13 == key && trIndex == trAllNums) {
        if ( event && event.stopPropagation ){
            //因此它支持W3C的stopPropagation()方法
            event.stopPropagation();
        }else{
            //否则,我们需要使用IE的方式来取消事件冒泡
            window.event.cancelBubble = true;
        }
        return false;
    }
}

 


转载:https://blog.csdn.net/qq_39822451/article/details/101271237
查看评论
* 以上用户言论只代表其个人观点,不代表本网站的观点或立场