I'm working in a little project with JQuery, and i having a problem removing error classes from html elements.
I'm using $('selector').on('input') to get the event and remove the input class, my problem is when the field is generated with JavaScript;
Example
$('#one').on('input',function(){
$('#two').val( $('#one').val() );
});
$(':input').on('input', function ()
{
if ($(this).hasClass('example'))
{
$(this).removeClass('example');
}
});
.example
{
color: orange;
background-color: black;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<h2>Normal Case</h2>
<input type="text" class="example">
<h2>Problem</h2>
<label for="one">#ONE</label>
<input type="text" class="example" id="one">
<br/>
<label for="two">#TWO</label>
<input type="text" class="example" readonly="readonly" id="two">
In this case, i change #two value when #one changes, #one remove .example but #two dont
I need to remove .example class from #two input
EDIT: I want to do it in a generic way because i have a LOT of this cases in my project
Is some way to trigger that kind of changes?
Thanks so much!