Good people.
I'm trying to fill an input itself to change its background-color
, this would have to be done dynamically, without having to click a button or reload the page. I have tried this, but it doesn't work:
function ActiveInputs() {
var gg = $('#search-form').find('input:text,select, textarea').val();
$(gg).on('blur', function () {
if ($(this).val() != '') {
$(this).css('background-color', 'red');
}
});
Someone gives me a hand?
You can use the :input selector to grab all the elements of the form. In the change event you check if it has a value and, depending on whether the value is empty or not, you assign the css class to change the background:
You could create a function to modify the css with jquery and execute directly through the onchange() event for example: