我想單擊相關標籤時爲以下圖像設置邊框顏色。有誰能夠幫助我?我試過用jQuery,但它不工作...謝謝你的幫助。單擊時設置邊框顏色
$("#fc-goal_1").click(function() {
$("#fc-goal_1").closest('#fc-goal_1').find('img').css("border", "2px solid rgb(99, 195, 195);");
});
\t $("#fc-goal_2").click(function() {
$("#fc-goal_2").closest('#fc-goal_1').find('img').css("border", "2px solid rgb(99, 195, 195);");
});
\t $("#fc-goal_3").click(function() {
$("#fc-goal_3").closest('#fc-goal_1').find('img').css("border", "2px solid rgb(99, 195, 195);");
});
\t $('#fc-goal_4').click(function() {
$('#fc-goal_4').closest('#fc-goal_1').find('img').css('border', '2px solid rgb(99, 195, 195);');
});
<div class="questions-fc-1 questions-fcm-2 radio-button">
<input checked="checked" id="muscle-goal_1" name="goal" class="goal" value="1" aria-required="true" type="radio">
<label id="fc-goal_1" aria-controls="#muscle-goal_1">
<img style="" src="/wp-content/uploads/2016/07/muskelaufbau.jpg" alt="Blaaaaa">
<span>Blaaaaa</span>
</label>
</div>
<div class="questions-fc-1 questions-fcm-2 radio-button">
<input checked="checked" id="weight-loss-goal_2" name="goal" class="goal" value="2" aria-required="true" type="radio">
<label id="fc-goal_2" aria-controls="#weight-loss-goal_2">
<img src="/wp-content/uploads/2016/07/abnehmen.jpg" alt="Blaaaaa">
<span>Blaaaaa</span>
</label>
</div>
<div class="questions-fc-1 questions-fcm-2 radio-button">
<input checked="checked" id="figure-workout-goal_3" name="goal" class="goal" value="3" aria-required="true" type="radio">
<label id="fc-goal_3" aria-controls="#figure-workout-goal_3">
<img src="/wp-content/uploads/2016/07/figurentraining.jpg" alt="Blaaaaa">
<span>Blaaaaa</span>
</label>
</div>
<div class="questions-fc-1 questions-fcm-2 radio-button">
<input checked="checked" id="health-goal_4" name="goal" class="goal" value="4" aria-required="true" type="radio">
<label id="fc-goal_4" aria-controls="#health-goal_4">
<img src="/wp-content/uploads/2016/07/gesundheit.jpg" alt="Blaaaaa">
<span>Blaaaaa</span>
</label>
</div>
<div class="error_content_box">
<div style="visibility: hidden;" class="error"></div>
</div>
哦好吧謝謝:)但我能做些什麼只做邊框顏色的選中?你懂?所以,當我點擊新的最後一個應該沒有邊界:我已經嘗試過,但我不知道:( – Johnny97
我更新了我的答案,告訴你如何 –