-2
나는 used.I라는 배열을 가지고 있는데 배열에 코드를 추가했지만 코드가 다시 추가되었는지 확인합니다. 그것이 추가 되었다면 "False"라고 말해야합니다. 그렇지 않은 경우 문제는 거짓말과 진실을 말할 것입니다.코드는 if 및 else 문을 모두 실행합니다. Javascript
var used=[];//use that to check if the user has added the code to favourites again
var x='',y='',blur='',r="",g="",b="",op="",color="rgb(0,0,0)",shadow=''; //create the variables that will be used
function update(){
x=$("#x").val();
y=$("#y").val();
op=$("#o").val();
r=$("#red").val();
g=$("#green").val();
b=$("#blue").val();
blur=$("#blur").val();
shadow = x+"px "+y+"px ";
}
$(document).ready(function(){
$("#addC").click(function(){
if(used.indexOf(shadow) != -1){
alert("false");
}
else{
used.push(shadow);
alert("True");
}
});
$('.shadow-slider').change(function(){
update();
if (op != 1){
if(op.length > 3){op=op.substring(0, 3);}
color="rgba("+r+","+g+","+b+","+op+")";
}
else{
color="rgb("+r+","+g+","+b+")";
}
if (blur != 0){shadow += blur+"px ";}
shadow += color;
$('#object').css("text-shadow",shadow);
$('#code-output').html("text-shadow:"+shadow+";");
});
});
그림자 내 page.Any 아이디어의 일부 슬라이더에 따라 변경 전역 변수입니다 : 여기 내 코드?
클릭 이벤트 처리기가 두 번 트리거됩니다. –
어디에서 두 번 실행됩니다. 아무 것도 볼 수 없습니다. – stranger4js