我正在使用类“gmapItems”动态创建元素。我需要为每个元素导出一个数组。
有任何想法吗?
HTML:
<div class="gmapItems">
<input type="text" class="input-medium googleMapCity" value='1'>
<input type="text" class="input-medium googleMapAddress" value='1'>
<textarea class="input-medium googleMapInformation" value='1'></textarea>
</div>
<div class="gmapItems">
<input type="text" class="input-medium googleMapCity" value='2'>
<input type="text" class="input-medium googleMapAddress" value='2'>
<textarea class="input-medium googleMapInformation" value='2'></textarea>
</div>
查询:
$("#AddGoogleMap").on('click', function () {
mapMarkers = new Array();
$('.gmapItems').each(function(){
gmapCity = $('.googleMapCity').val();
gmapAddress = $('.googleMapAddress').val();
gmapInfo = $('.googleMapInformation').val();
mapMarkers.push(gmapCity, gmapAddress, gmapInfo);
alert(mapMarkers)
});