📌  相关文章
📜  js 检查数据库中的字段是真还是假 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:01:37.003000             🧑  作者: Mango

代码示例1
let taskDone = document.querySelectorAll('.taskDone'); //get all the chechbox with same class .taskDone
taskDone.forEach(function(btn) { //use normal function
  btn.addEventListener('change', function() {
    let id = $(this).data('id') //get the data id of checkbox
    if ($(this).is(':checked')) { //check if the clicked checkbox is checked or not
      console.log(id + ' is Checked - Updating neDB') //console.log
      $.ajax({
        url: 'http://localhost:3000/done/' + id,
        type: 'PUT',
        data: 'isDone'
      }).done(function(data) {
        console.log(data)
      })
    } else {
      console.log("Not Checked")
    }
  })
})