0

I have a form with dynamic text boxes and fetches data from the backend. When user clicks on the text-box, the color of the text in the text box changes and when the form is submitted, a confirmation message is displayed and with it, I want the text boxes color to be changed back to black. I have tried changing the color, but it is not happening. Here is my code:

    $.ajax({

        type: "POST",
        dataType: "html",
        url: "update.php",
        data: {'postData':JSON.stringify(postData)},
        contentType: 'application/x-www-form-urlencoded; charset=UTF-8',
        success: function(data) {
            successmessage = 'Rows updated successfully';
            $("#contentsID").text(successmessage);
            var checkboxes = $("input[type='checkbox']");
            var textBoxes = $("input[type = 'text']");
            textBoxes.attr("disabled", checkboxes.is(":checked"));
            $('#varEdit').prop('checked', false);
            $('#saveEdits').prop('disabled', true);
            textBoxes.text.style.color ='#000000';
            //textBoxes.style.color = '#000000';

        },

can someone take a dig on it.

Smern
  • 18,746
  • 21
  • 72
  • 90
user4943236
  • 5,914
  • 11
  • 27
  • 40
  • understand difference between `Jquery object and dom ` http://stackoverflow.com/questions/6974582/jquery-object-and-dom-element – Tintu C Raju Oct 26 '15 at 04:44

2 Answers2

3

Try

$('input[type="text"]').css('color','#000');

instead of

textBoxes.text.style.color ='#000000';
Nere
  • 4,097
  • 5
  • 31
  • 71
1

textBoxes hold jquery obj, then use :

textBoxes.css('color','#000');

Otherwise use :

textBoxes[0].style.color ='#000';
Norlihazmey Ghazali
  • 9,000
  • 1
  • 23
  • 40
  • i would assume that textBoxes contains multiple, so would want to loop them rather than just change the first occurrence (this comment is only directed at the second solution). – Smern Oct 26 '15 at 04:46