angularjs语法错误无法识别的表达式

时间:2016-06-08 13:08:22

标签: javascript jquery angularjs

var solveOptionOther =“\'”+“#”+ a +“\'”;

错误:语法错误,无法识别的表达式:'#option2

这是我的功能 -

 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 :(得分:0)

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

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

您只需要:

var solvedOptionOther = "#"+ a;