0
매개 변수가 선택적인지 확인해야합니다. 그 말이 맞는다면.JavaScript의 경우 매개 변수 인 경우 이미지의 투명도 무시
내 기능이 모두 98 %라는 것을 알게되면이 차이를 매개 변수로 바꾸어서 나를 클릭하지 않아도됩니다. 새 매개 변수 클래스는 내가 // 여기 내 코드
//get the element under the mouse, ignoring all transparency.
function getElement(x, y){
var elem = document.elementFromPoint(x, y);
if($(elem).parents("#game").length != 1){ return -1; }
var pixelAlpha = mousePixelOpacity(elem, x, y);
var track = Array;
for(var i = 0;i<50;i++){
if($(elem).attr("id") == "game"){ return -1;}
if(pixelAlpha == 0){ /////////////////////////////////////////HERE
track[i] = elem;
for(var z = 0; z<i+1; z++){ //hide elements
$(track[z]).hide();
}
elem = document.elementFromPoint(x, y); //set the element right under the mouse.
pixelAlpha = mousePixelOpacity(elem, x, y);
for(var z = 0; z<i+1; z++){ //show all the recently hidden elements
$(track[z]).show();
}
}
if(pixelAlpha != 0){ ///////////////////////////////////////// AND HERE
return elem;
}
}
return -1;
}
//get the tile under the mouse, even if it's behind an object
function getTile(x, y){
var elem = document.elementFromPoint(x, y);
if($(elem).parents("#game").length != 1 && $(elem).attr("id") != "tileHighlight"){ return -1; }
var pixelAlpha = mousePixelOpacity(elem, x, y);
var track = Array;
for(var i = 0;i<50;i++){
if($(elem).attr("id") == "game"){ return -1;}
if(pixelAlpha == 0 || $(elem).attr('class') != "tile"){ /////////HERE
track[i] = elem;
for(var z = 0; z<i+1; z++){ //hide elements
$(track[z]).hide();
}
elem = document.elementFromPoint(x, y); //set the element right under the mouse.
pixelAlpha = mousePixelOpacity(elem, x, y);
for(var z = 0; z<i+1; z++){ //show all the recently hidden elements
$(track[z]).show();
}
}
if($(elem).attr('class') == "tile" && pixelAlpha != 0){ ///// AND HERE
return elem;
}
}
return -1;
}
내가
getElement(x, y, "title");
//(This can be right) OR (both of these can be right.)
if((pixelAlpha == 0) || (class="tile" && onlycountclassifIsaidsovar)){}
같은 것을 생각에서로 표시 한 내용을 변경
getElement(x, y, class)
그런데 나는에있다. 이 강아지의 행동을보고 싶다면210 점.
감사합니다.
고마워요.하지만 토글을 켜고 끄고 싶지 않습니다. 토글이 켜져 있음을 의미하는 문자열을 입력하고 주어진 문자열에서 클래스를 선택하고 싶습니다. –