2017-09-07 1 views
-1

두 번째 확인란을 클릭하면 첫 번째 확인란이 활성화됩니다.원하는 확인란이 활성화되지 않음

하지만 첫 번째 확인란을 클릭하면 모든 것이 정상적으로 작동합니다.

두 번째 확인란을 클릭하고 무슨 일이 일어나는지 확인하십시오.

1000 개의 확인란이 있습니다.변경 ID는 좋지 않습니다!

자세한 내용이 필요하면 질문에 대한 의견을 말하십시오.

.checkboxFour{ 
 
\t width: 14px; 
 
\t height: 14px; 
 
\t background: #dddddd; 
 
\t margin: 0px 0px; 
 
\t border-radius: 100%; 
 
\t position: absolute; 
 
\t margin-top: -20px; 
 
\t margin-right: -18px; 
 
} 
 
.checkboxFour > input{visibility: hidden;/* position: absolute; *//* z-index:-1000; *//* overflow: hidden; *//* clip: rect(0 0 0 0); */height: 17px;width: 14px;margin: -2px;margin-right: -7px;padding:0;border:0;} 
 
.checkboxFour label{ 
 
\t width: 10px; 
 
\t height: 10px; 
 
\t border-radius: 100px; 
 
\t transition: all .5s ease; 
 
\t cursor: pointer; 
 
\t top: 0px; 
 
\t position: absolute; 
 
\t left: 2px; 
 
\t z-index: 1; 
 
\t background: #ddd; 
 
\t margin-top: 2px; 
 
\t margin-right: 2px; 
 
} 
 
.checkboxFour input[type=checkbox]:checked + label { 
 
\t background: #f83232; 
 
}
<br> 
 
<br> 
 
<br> 
 
<td><div class="checkboxFour"><input type="checkbox" value="1" id="checkboxFourInput" name=""><label for="checkboxFourInput"> </label> Important</div></td> 
 
<br><br><br><br><br> 
 
<td><div class="checkboxFour"><input type="checkbox" value="1" id="checkboxFourInput" name=""><label for="checkboxFourInput"> </label> </div>Not Important</td>

감사합니다 :

은 여기 봐주십시오 코드입니다!

+1

"변경 ID는 좋지 않습니다."- 네, 맞습니다. – Quentin

+0

모든 요소마다 고유 ID가 필요합니다. 동적 ID –

답변

0

당신이 입력에 동일한 ID-S를 넣어 가지고 있기 때문에이 발생, 모두 라벨이 해당 ID를 참조했다 :

.checkboxFour{ 
 
\t width: 14px; 
 
\t height: 14px; 
 
\t background: #dddddd; 
 
\t margin: 0px 0px; 
 
\t border-radius: 100%; 
 
\t position: absolute; 
 
\t margin-top: -20px; 
 
\t margin-right: -18px; 
 
} 
 
.checkboxFour > input{visibility: hidden;/* position: absolute; *//* z-index:-1000; *//* overflow: hidden; *//* clip: rect(0 0 0 0); */height: 17px;width: 14px;margin: -2px;margin-right: -7px;padding:0;border:0;} 
 
.checkboxFour label{ 
 
\t width: 10px; 
 
\t height: 10px; 
 
\t border-radius: 100px; 
 
\t transition: all .5s ease; 
 
\t cursor: pointer; 
 
\t top: 0px; 
 
\t position: absolute; 
 
\t left: 2px; 
 
\t z-index: 1; 
 
\t background: #ddd; 
 
\t margin-top: 2px; 
 
\t margin-right: 2px; 
 
} 
 
.checkboxFour input[type=checkbox]:checked + label { 
 
\t background: #f83232; 
 
}
<br> 
 
<br> 
 
<br> 
 
<td><div class="checkboxFour"><input type="checkbox" value="1" id="checkboxFourInput" name=""><label for="checkboxFourInput"> </label> Important</div></td> 
 
<br><br><br><br><br> 
 
<td><div class="checkboxFour"><input type="checkbox" value="1" id="checkboxFourInput2" name=""><label for="checkboxFourInput2"> </label> </div>Not Important</td>

+0

다른 방법이 필요합니다! 나는 1000 개의 체크 박스를 가지고있다! – Alireza

+1

각 체크 박스에는 특정 ID가 있어야합니다! @Alireza –

+0

오! 승인.......... – Alireza

0

.checkboxFour{ 
 
\t width: 14px; 
 
\t height: 14px; 
 
\t background: #dddddd; 
 
\t margin: 0px 0px; 
 
\t border-radius: 100%; 
 
\t position: absolute; 
 
\t margin-top: -20px; 
 
\t margin-right: -18px; 
 
} 
 
.checkboxFour > input{visibility: hidden;/* position: absolute; *//* z-index:-1000; *//* overflow: hidden; *//* clip: rect(0 0 0 0); */height: 17px;width: 14px;margin: -2px;margin-right: -7px;padding:0;border:0;} 
 
.checkboxFour label{ 
 
\t width: 10px; 
 
\t height: 10px; 
 
\t border-radius: 100px; 
 
\t transition: all .5s ease; 
 
\t cursor: pointer; 
 
\t top: 0px; 
 
\t position: absolute; 
 
\t left: 2px; 
 
\t z-index: 1; 
 
\t background: #ddd; 
 
\t margin-top: 2px; 
 
\t margin-right: 2px; 
 
} 
 
.checkboxFour input[type=checkbox]:checked + label { 
 
\t background: #f83232; 
 
}
<br> 
 
<br> 
 
<br> 
 
<td><div class="checkboxFour"><input type="checkbox" value="1" id="checkboxFourInput" name=""><label for="checkboxFourInput"> </label> Important</div></td> 
 
<br><br><br><br><br> 
 
<td><div class="checkboxFour"><input type="checkbox" value="1" id="checkboxFourInput_2" name=""><label for="checkboxFourInput_2"> </label> </div>Not Important</td>

변화 당신의 for와 두 번째 레이블과 사업부의 id

+0

다른 방법이 필요합니다! 1000 체크 박스가 있습니다! – Alireza

+1

그러면 beetwen에 대해 잘 모릅니다 '와'id '가 사용됩니다 –

관련 문제