본문 바로가기

웹 프로그래밍/JavaScript

[JS] 인용부호가 요구됩니다.

쌍따옴표는 다 \ 역슬래쉬로 처리했는데도 이런 에러가 떴다.

아무래도, javascript 함수 내에서 JSTL을 써서 그런거같은데.. 잘모르겠다.

 

그래서 <c:when> 등의 태그를 다 없애고 javascript 코드로 바꾸었다. 그러니 실행되었음!

 

 

에러가 나던 js 내의 함수 코드

				     addListHtml += "<li>";
	            	 addListHtml += "<div style = \"background-color: #E8F5FF;\">";
	            	 addListHtml += "<span style = \"vertical-align: middle; font-weight : bold; font-size: 100px; color: black;\">" + (index+1) + "</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
	            	 addListHtml += "<span>";
	            	 addListHtml += "<c:choose>";
	            	 addListHtml += "<c:when test=\" " +  this.cardName.substring(0,1) + " == '#'    \">";
	            		 
	            	 addListHtml += "<img src=\"/hanacard-spring-mvc/resources/images/" + this.cardName.substring(1, this.cardName.length)  + ".png\" style = \"width : 132px; height : 84px;\">";
	            	 addListHtml += "</c:when>";
	            	 
	            	 addListHtml += "<c:otherwise>";
	            	 addListHtml += "<img src=\"/hanacard-spring-mvc/resources/images/" + this.cardName + ".png\" style = \"width : 132px; height : 84px;\">";
	            	 addListHtml += "</c:otherwise>";
	            	 addListHtml += "</c:choose>";
	            	 addListHtml += "</span>";
	            	 addListHtml += "&nbsp;&nbsp;&nbsp;&nbsp;";
	            	 addListHtml += "<span style =\"font-size: 30px; vertical-align: sub; color: black;\">" + this.cardName + "</span>";
	            	 addListHtml += "</div>";
	            	 addListHtml += "</li>";
	            	 addListHtml += "<br>";

 

잘 실행되는 코드

 $(list).each(function(index){
	            	 
	            	 alert('this.cardName.substring(0,1) ===> ' + this.cardName.substring(0,1) );
	            	 
	            	 addListHtml += "<li>";
	            	 addListHtml += "<div style = \"background-color: #E8F5FF;\">";
	            	 addListHtml += "<span style = \"vertical-align: middle; font-weight : bold; font-size: 100px; color: black;\">" + (index+1) + "</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
	            	 addListHtml += "<span>";
	            	 
	            	 
	            	 
	            	 if(this.cardName.substring(0,1) == '#'){
	            		 
		            	 addListHtml += "<img src=\"/hanacard-spring-mvc/resources/images/" + this.cardName.substring(1, this.cardName.length)  + ".png\" style = \"width : 132px; height : 84px;\">";

	            	 } else{
	            		 
		            	 addListHtml += "<img src=\"/hanacard-spring-mvc/resources/images/" + this.cardName + ".png\" style = \"width : 132px; height : 84px;\">";

	            	 }
	            	 
	            	 addListHtml += "</span>";
	            	 addListHtml += "&nbsp;&nbsp;&nbsp;&nbsp;";
	            	 addListHtml += "<span style =\"font-size: 30px; vertical-align: sub; color: black;\">" + this.cardName + "</span>";
	            	 addListHtml += "</div>";
	            	 addListHtml += "</li>";
	            	 addListHtml += "<br>";
	            	 
	            	 /* addListHtml += this.cardName.substring(0,1);
	            	 addListHtml += this.cardName;
	            	 addListHtml += this.count; */
	            	 
	             })