mercredi 27 avril 2016

Get checkbox values without Id JQuery

I am iterating through a dynamically created table which has rows that contain plain text, checkboxes, and select drop down boxes. While iterating through the table with

$('#myTableId td').each ->
  thisSelect = $(this).find("option:selected").text()
  if thisSelectBox != ""
    allSelectValues.splice selectCounter,0, thisSelectBox
    selectCounter++

So this code works to get my select values, and I am using a similar approach for the text boxes. My issue though is getting the checkbox values. Since the table is dynamically created, I cant get the checkbox values by id since the table is dynamically created and when I try to use this code:

$('#tableId td').each ->
   thisCheckbox = $(this).find("input.classNameOfCheckbox:checkbox").val()

It returns "on" when iterating on a td that contains a checkbox whether or not it was checked. So my question is what is the best approach for this problem?




Aucun commentaire:

Enregistrer un commentaire