Search code examples
jqueryformscssinputinput-field

Jquery event on input change with specific class


I need to trigger a function when an input text field with a specific CSS class is changed.

    <form class="form-horizontal" role="form" id="infoClient">
                                <div class="form-group">
                                    <label for="Input" class="col-md-2 col-sm-2 control-label greenIfNotEmpty">Prénom</label>
                                    <div class="col-md-4 col-sm-4">
                                        <div class="input-group">
                                            <input type="text" class="form-control" id="Input" placeholder="">
                                            <span class="input-group-addon">
                                                <i class="glyphicon  glyphicon-pencil"></i>
                                            </span>
                                        </div>
                                    </div>
                                    <label for="disabledTextInput" class="col-md-2 col-sm-2 control-label greenIfNotEmpty">Nom famille</label>
                                    <div class="col-md-4 col-sm-4">
                                        <div class="input-group">
                                            <input type="text" id="disabledTextInput2" class="form-control" placeholder="">
                                            <span class="input-group-addon">
                                                <i class="glyphicon  glyphicon-pencil"></i>
                                            </span>
                                        </div>
                                    </div>
                                </div>



    $('input[type='text']').change(function() { ... });

This works for every input field,

$('input[type='text'] .greenIfNotEmpty').change(function() { ... });

is not working.

Can anyone help me on this ?


Solution

  • I feel dumb, I've attached class to Label instead of Input. Thanks a lot everybody.