问题描述图片描述浏览器报错,(找不到className,是这个意思吗?),应该怎么解决呢。还有一个问题,传入的值为元素,元素是个什么定义呢?相关代码这是前端页面特性分支集成分支历史版本这是common.jsfunctionhasClass(elementone,cName){if(!elementone||elementone.className==null){returnfalse;}return!!elementsone.className.match(newRegExp("(\\s|^)"+cName+"(\\s|$)"));}functionaddClass(elementOne,cName){if(!hasClass(elementOne,cName)){elementOne.className+=""+cName;//这里是common.js第96行};}functionremoveClass(elementOne,cName){if(hasClass(elementOne,cName)){elementOne.className=elementOne.className.replace(newRegExp("(\\s|^)"+cName+"(\\s|$)"),"");//replace方法是替换};}这是方法的调用:functiononloadTable(){varBranchTypeID=getCookie("BranchTypeID");varfeatureLi=document.getElementById("featureLi");varintegrationLi=document.getElementById("integrationLi");varpublishedLi=document.getElementById("publishedLi");varFeature=document.getElementById("Feature");varIntegration=document.getElementById("Integration");varPublished=document.getElementById("Published");if(BranchTypeID==1){//为这个类移除属性addClass(featureLi,"active");removeClass(integrationLi,"active");removeClass(publishedLi,"active");$("#featureA").attr("aria-expanded","true");$("#integrationA").attr("aria-expanded","false");$("#publishedA").attr("aria-expanded","false");addClass(Feature,"active");removeClass(Integration,"active");removeClass(Published,"active");}if(BranchTypeID==2){//为这个类移除属性removeClass(featureLi,"active");addClass(integrationLi,"active");removeClass(publishedLi,"active");removeClass(Feature,"active");addClass(Integration,"active");removeClass(Published,"active");$("#featureA").attr("aria-expanded","false");$("#integrationA").attr("aria-expanded","true");$("#publishedA").attr("aria-expanded","false");}if(BranchTypeID==3){//为这个类移除属性removeClass(featureLi,"active");removeClass(integrationLi,"active");addClass(publishedLi,"active");$("#featureA").attr("aria-expanded","false");$("#integrationA").attr("aria-expanded","false");$("#publishedA").attr("aria-expanded","true");removeClass(Feature,"active");removeClass(Integration,"active");addClass(Published,"active");}setInterval("checkPipelineStatus()",10000);}
2 回答
呼如林
TA贡献1798条经验 获得超3个赞
看了下代码,你传入addClass,removeClass,hasClass的第一个参数应该element的但是你传入的却是element的className也就是一个字符串
小唯快跑啊
TA贡献1863条经验 获得超2个赞
varapplyMergeLi=document.write(document.getElementById('applyMergeLi').className);varapplyPublishLi=document.getElementById("applyPublishLi").className;varmergeReviewLogLi=document.getElementById("mergeReviewLogLi").className;varpublishReviewLogLi=document.getElementById("publishReviewLogLi").className;varApplyMerge=document.getElementById("ApplyMerge").className;varApplyPublish=document.getElementById("ApplyPublish").className;varMergeReviewLog=document.getElementById("MergeReviewLog").className;varPublishReviewLog=document.getElementById("PublishReviewLog").className;每行去掉.className第一个再去掉document.write
添加回答
举报
0/150
提交
取消