$("선택자").click(e => {
...
})
// 또는
$("선택자").click(function(e){
...
})
// 또는
$("선택자").bind('click', function(e){
...
}
선택자.eq(index값) : 선택자(유사배열) 중 index 값에 해당하는 선택자를 얻어오는 것
$("선택자").click(e => {
const i = $("선택자").index($(e.target));
$("선택자").each(function(index, elmt){
if(index == i){
$(elmt).css({"background-color":"green"});
}
else{
$(elmt).css({"background-color":""});
} // end of if~else-----
} // end of $("선택자").each(function(index, elmt)-------
}) // end of $("선택자").click(e => {})-------------------------
$("선택자").click(e => {
const i = $("선택자").index($(e.target));
for(let index=0; index<배열명.length; index++){
if(index == i){
$("선택자").eq(index).css({"background-color":"green"});
// 또는
document.querySelector("선택자")[index]
.css({"background-color":"green"});
}
else{
$("선택자").eq(index).css({"background-color":""});
// 또는
document.querySelector("선택자")[index]
.css({"background-color":""});
} // end of if~else-------
} // end of for---------------------
}) // end of $("선택자").click(e => {})-----------------
// === 기본 처음 이미지 설정 === //
$("선택자").eq(0).trigger('click');