Home > DeveloperSection > Forums > How to change value of input with jquery under this class?
Andrew Watson
Andrew Watson

Total Post:39

Posted on    January-30-2015 10:14 PM

 ASP.Net JQuery  JavaScript  HTML 

 1 Reply(s)
 823  View(s)
Rate this:




    $(this).closest('.row').children('.abc').hide(); // working

    $(this).closest('.row').children('.abc').children('input').value = ''; // not working

    $(this).closest('.bookingrow').children('.addressbox').children('input').value(''); // alternative - not working



<div class="row">

  <div class='abc'>

     <input type='text' class='unknown' />


  <div class="clickhere">hide</div>


my target is if i click the "clickhere" class, content under "abc" class will hide and whatever content added by customer on those input box, they will be clear.

same html used multiple time on the same form. that's why using "$(this)".
any solution? what i am doing wrong?
Thanks in advance.

jayprakash sharma
jayprakash sharma

Total Post:117

Posted on    January-30-2015 10:30 PM

You need to use .val() to set the value, jQuery methods normally will return a jQuery object not a dom element reference so you would not have a properly called .value.

$(this).closest('.row').find('.abc input').val('');


$('.clickhere').click(function (e) {


    //cache the value of .row since it is used multiple times

    var $row = $(this).closest('.row');

    $row.children('.abc').hide(); // working

    $row.find('.abc input').val('');


Modified On Mar-15-2016 05:25:04 AM

Don't want to miss updates? Please click the below button!

Follow MindStick