change the background color of inputted text in search/input box and remove color if no text

change the background color of inputted text in search/input box and remove color if no text

soma1204soma1204 Posts: 34Questions: 6Answers: 0

Hi,

i want to change the background color of text when text exist in input box and remove color when text is removed.
Do we have any option of it?

Thanks
Soma

Answers

  • soma1204soma1204 Posts: 34Questions: 6Answers: 0

    This is search-box in databtables.

  • colincolin Posts: 15,177Questions: 1Answers: 2,590

    You can use search to trigger the colour change - something like this:

      table.on('search', function() {
        $('.dataTables_filter input').css('background-color', table.search() === ''? 'transparent' : 'red')
      })
    

    Colin

  • soma1204soma1204 Posts: 34Questions: 6Answers: 0

    It worked. Thanks Colin for quick help.
    Appreciate your time.

    Thanks
    Soma

Sign In or Register to comment.