문제

How can I make it more easier?

$("#one").click(function() { $("#container").fadeOut(200); }); $("#two").click(function() { $("#container").fadeOut(200); }); $("#three").click(function() { $("#container").fadeOut(200); }); $("#four").click(function() { $("#container").fadeOut(200); });

도움이 되었습니까?

해결책

Either add class to each element .class

$('.class').click(function () {
    $("#container").fadeOut(200);
});

or combine the ids to the selector

$('#one,#two,#three,#four').click(function () {
    $("#container").fadeOut(200);
});
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top