說明:我試圖做一個公認的對講系統,有三種情況:如何創建一個標記作爲被接受的系統答案?
- 標誌着一個新的答案,接受一個(已經不存在公認的答案)
- 撤消一個公認的答案
- 從一個答案切換到另一個
這裏是我的代碼:
$("body").on('click', '.fa-check', function(e) {
// send a request by ajax and if it is successful then
if(this.attr('color') == '#44b449'){ // undo
this.css({"color":"#aaa"}); // set gry color to marked icon
} else { // switchin or marking a new one
$('.fa-check').css({"color":"#aaa"}); // set gray color to all icons
this.css({"color":"#44b449"}); // set green color to marked icon
}
\t
});
.fa-check{
color:#aaa;
cursor: pointer;
}
.fa-check:hover{
color: #999;
}
<script src="https://use.fontawesome.com/9e9ad91d21.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<p>answer1</p>
<i class="fa fa-check" aria-hidden="true"></i>
<hr>
<p>answer2</p>
<i class="fa fa-check" aria-hidden="true" style="color: #44b449;"></i>
<hr>
<p>answer3</p>
<i class="fa fa-check" aria-hidden="true"></i>
但是當你看到我的代碼不能正常工作。我該如何解決它?
注:我的整個問題都是關於着色。
可以請你告訴我,我的問題已獲得downvote? – stack