Search code examples
jqueryjquery-selectors

How to select two elements inside a div in jquery


I have a div with class footer-contact and inside that div, I have several input and textarea elements. I want to empty their text. I tried using the following selector but it doesn't work. What am I doing wrong?

$(".footer-contact input[type=text] textarea").val('');

Solution

  • $(".footer-contact,input[type=text],textarea").val('');
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    <input type='text' class='footer-contact' value='asdas'>
    <input type='text' value='asdas'>
    <textarea>asdas</textarea>

    1. add comma
    2. if there is no comma it will look for child