2016-06-08 95 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

謝謝你,它工作 –

相關問題