change background color of column search field

Questionschange background color of column search field
Harry asked 9 years ago

Hi I would like to change the background color of the search field on top of the column when it contains a search term. When its empty it should return to transparent. How may I accomplish this?

I tried

jQuery(document).ready(function(){

if(jQuery("th.ui-state-default.ui-th-column.ui-th-ltr").val()!="")

{jQuery(this).css('background-color','#00FF00');}

else

{jQuery(this).css('background-color','#0000ffff');}

});

Thank you

4 Answers
Abu Ghufran answered 9 years ago

Hi,

I don't understand exactly what you are trying to get … but the jquery selector will also have input at end:

Replace:
if(jQuery("th.ui-state-default.ui-th-column.ui-th-ltr").val()!="")
{…}

With:
if(jQuery("th.ui-state-default.ui-th-column.ui-th-ltr input").val()!="")
{…}

Harry answered 9 years ago

I tried your recommendation

jQuery(document).ready(function(){

if(jQuery("th.ui-state-default.ui-th-column.ui-th-ltr input").val()!="")

{jQuery(this).css('background-color','#00FF00');}

else

{jQuery(this).css('background-color','#0000ffff');}

});

but it didn't work.

The aim is of the code is to check if any of the search fields on top of the grid columns has a value .
If there is a value then the background color changes for emphasis and remains changed as long as a non-null or non-zero value is there.

Abu Ghufran answered 9 years ago
Harry answered 9 years ago

That works, thank you.

Your Answer

12 + 0 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?