2016-06-08 137 views
-3

var resolvedOptionOther =“\'”+“#”+ a +“\'”;angularjs语法错误无法识别的表达式

错误:语法错误,无法识别的表情:“#1选项

这是我function--

if ($scope.solvedQuestionId.contains(otherQuestionID)) { 

     $scope.otherid= otherQuestionID; 
     var optionIndex = $scope.solvedQuestionId.indexOf(parseInt($scope.otherid)) + 1; 
     $scope.optionOtherIndex = optionIndex; 
     var a = $scope.solvedQuestionId[optionIndex] 
     var solvedOptionOther = "\'" +"#"+ a + "\'"; 
     alert(solvedOptionOther); 

     $(".option").css("border","none"); 
    /* $("#" +$scope.optionOtherIndex).css("border","none");*/ 

     $('.option').css('pointer-events','none'); 
     $("#" +$scope.answersOfQuestion.answer).css("border","green solid 2px"); 
     alert("solved"); 
     $(solvedOptionOther).css("border","red solid 2px"); 


    } 
+1

你有什么问题吗?我们可以假设几件事情,但你必须更精确 –

+0

var resolvedOptionOther =“\'”+“#”+ a +“\'”; (获取错误:语法错误,无法识别的表达式)在这一行 –

回答

0

没有理由将其包装在单引号

如果你硬编码什么你在做,你会有这个选择器:$("'#option2'")

所有你需要的是:

var solvedOptionOther = "#"+ a; 
+0

谢谢你,它工作 –

相关问题