This question already has an answer here: 這個問題在這裏已有答案: jquery
I have some input text fields in my page and am displaying their values using JavaScript. 個人頁面中有一些輸入文本字段,並使用JavaScript顯示其值。 ide
I am using .set("value","")
function to edit the value, add an extra checkbox field, and to pass a value. 我使用.set("value","")
函數來編輯值,添加一個額外的複選框字段,並傳遞一個值。 函數
Here I want to check that if value == 1
, then this checkbox should be checked. 在這裏,我想檢查若是value == 1
,則應選中此複選框。 Otherwise, it should remain unchecked. 不然,它應該保持未選中狀態。 this
I did this by using two divs, but I am not feeling comfortable with that, is there any other solution? 我經過使用兩個div來作到這一點,但我對此感到不舒服,還有其餘解決方案嗎? spa
if(value == 1) { $('#uncheck').hide(); $('#check').show(); } else{ $('#uncheck').show(); $('#check').hide(); }