简体   繁体   中英

simultaneously change all input values

How could I clear (ie set to "") all the input values at once?

<div id="hidden-inputs">
  <input type="hidden" value="9013 NE Hwy 99" id="adderss_copy" name="adderss_copy">
  <input type="hidden" value="Vancouver" id="city_copy" name="city_copy">
  <input type="hidden" value="WA" id="states_id_copy" name="states_id_copy">
  <input type="hidden" value="98665" id="zipcode" name="zipcode">
  <input type="hidden" value="Clark County" id="county" name="county">
  <input type="hidden" value="US" id="country" name="country">
  <input type="hidden" value="45.687949" id="latitude" name="latitude">
  <input type="hidden" value="-122.659134" id="longitude" name="longitude">
  <input type="hidden" value="" id="timezone" name="timezone">
</div>

I've unsuccessfully tried the following:

$('#hidden-inputs').find(':input').val('');
$('#hidden-inputs :input').val('');

尝试

$('#hidden-inputs input').val('');

Try

Wrap your code in DOM Ready

$(function () {
    $('#hidden-inputs input').val('');
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM