css - use jQuery to set search field background colour if field has search term -


hi have table search field on of columns.

i use jquery have background of search field change colour when term has been entered, i.e. change colour when not null or 0 or has count of 0 characters , remain changed long field has search term.

the class of fields background colour should changed is

class="ui-state-default ui-th-column ui-th-ltr" 

i understand convention have code begin very, new jquery.

the css:

field.data {     background-color: green; } 

the script

jquery(document).ready(function(){  //test if field tagged class contains //if set background //if doesn't unset background  }); 

try this

$('.ui-state-default').blur(function() {    if ($(this).val() == '') {      $(this).removeclass('data');    } else {      $(this).addclass('data');    }  })
.data {    background-color: green;  }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>  <input type="text" class="ui-state-default ui-th-column ui-th-ltr" />


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -