How do I detect a text input's value and set a class with jQuery?

Posted by Zander on Stack Overflow See other posts from Stack Overflow or by Zander
Published on 2010-04-14T21:44:03Z Indexed on 2010/04/14 21:53 UTC
Read the original article Hit count: 110

Filed under:

I would like to make sure if a textbox has any content at all, that jQuery can show it's parent (an <li class="hidden_dedication">) element and set add a class of 'shown'. I'm pretty sure that it should be something like this, but cannot get it to work:

    if ($('li.hidden_dedication input').val() !== null) {
         $(this).parent().show().addClass('shown');
    }

I cannot figure it out.. any ideas?

Many thanks

© Stack Overflow or respective owner

Related posts about jQuery