jQuery iterating through inputs not working

user3476093

I have a HTML div (f) with inputs in, and I would like it to be that when the input is clicked off, it changes to the bad_input class that I have specified (background color is red). However, this does not work and I am unsure of how to fix it. The inputs have placeholder tags, however, I am sure this is not the reason why it is not working.

$("#f input").blur(function()
    {
    if (!$(this).val())
        {
        $(this).attr('class', 'bad_input');
        }
    });
sanjeev

User .addClass() jquery method to add the class, not attr()

What you are doing will add a attribute with class = "bad_input" in the input

        $("#f input").blur(function()
            {
            if (!$(this).val())
                {
                  $(this).addClass('bad_input');
                }
            });

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

jQuery .remove() not working when iterating through variable

From Dev

Iterating through a json in jquery

From Dev

Iterating through a jQuery array

From Dev

Storing and Iterating through user inputs in C

From Dev

iterating through array of objects with jquery

From Dev

Iterating through list elements - jQuery

From Dev

JQuery iterating through a loop on click

From Dev

Iterating Through multiple dropdowns in jquery

From Dev

Iterating through list elements - jQuery

From Dev

JQuery .each loop not working when iterating through elements with dynamic class name

From Dev

JQuery .each loop not working when iterating through elements with dynamic class name

From Dev

parsing stringstream iterating through content not working

From Dev

AngularJS: code not working when iterating through object

From Dev

Jquery Not working to create new Inputs

From Dev

iterating through and showing hidden child divs jquery

From Dev

jQuery: Iterating through each element with CSS class

From Dev

Iterating Through Sequential Nested Classes in jQuery?

From Dev

Iterating through elements returned by jQuery selector

From Dev

use jquery to add to a table through inputs

From Dev

jquery to iterate through list items with nested inputs

From Dev

jquery validate plugin on dynamic form inputs not working

From Dev

jQuery: Trimming not working for checking empty inputs

From Dev

jQuery: Trimming not working for checking empty inputs

From Dev

product/add of dynamically added inputs not working jquery

From Dev

Java: Iterating through XML file - hasChildNodes() test not working as I imagined

From Dev

Can I save dynamic form with html() rather than iterating through INPUTs?

From Dev

Changing value of Plain Object properties while iterating through it with jQuery $.each

From Dev

Changing value of Plain Object properties while iterating through it with jQuery $.each

From Dev

Iterating through table and get the value of a button in each tablerow jQuery

Related Related

  1. 1

    jQuery .remove() not working when iterating through variable

  2. 2

    Iterating through a json in jquery

  3. 3

    Iterating through a jQuery array

  4. 4

    Storing and Iterating through user inputs in C

  5. 5

    iterating through array of objects with jquery

  6. 6

    Iterating through list elements - jQuery

  7. 7

    JQuery iterating through a loop on click

  8. 8

    Iterating Through multiple dropdowns in jquery

  9. 9

    Iterating through list elements - jQuery

  10. 10

    JQuery .each loop not working when iterating through elements with dynamic class name

  11. 11

    JQuery .each loop not working when iterating through elements with dynamic class name

  12. 12

    parsing stringstream iterating through content not working

  13. 13

    AngularJS: code not working when iterating through object

  14. 14

    Jquery Not working to create new Inputs

  15. 15

    iterating through and showing hidden child divs jquery

  16. 16

    jQuery: Iterating through each element with CSS class

  17. 17

    Iterating Through Sequential Nested Classes in jQuery?

  18. 18

    Iterating through elements returned by jQuery selector

  19. 19

    use jquery to add to a table through inputs

  20. 20

    jquery to iterate through list items with nested inputs

  21. 21

    jquery validate plugin on dynamic form inputs not working

  22. 22

    jQuery: Trimming not working for checking empty inputs

  23. 23

    jQuery: Trimming not working for checking empty inputs

  24. 24

    product/add of dynamically added inputs not working jquery

  25. 25

    Java: Iterating through XML file - hasChildNodes() test not working as I imagined

  26. 26

    Can I save dynamic form with html() rather than iterating through INPUTs?

  27. 27

    Changing value of Plain Object properties while iterating through it with jQuery $.each

  28. 28

    Changing value of Plain Object properties while iterating through it with jQuery $.each

  29. 29

    Iterating through table and get the value of a button in each tablerow jQuery

HotTag

Archive