I have some HTML like:
<div class="blah">
<span class="fileName">1.jpg</span>
</div>
<div class="blah">
<span class="fileName">2.jpg</span>
</div>
<div class="blah">
<span class="fileName">3.jpg</span>
</div>
<div class="blah">
<span class="fileName">4.jpg</span>
</div>
I want to get the file names with jQuery(a variable that stores smth like 1.jpg,2.jpg,3.jpg,4.jpg).
I finally could do it with an hidden input box, this is my working script:
<input type="hidden" id="img_names_input" />
<script>
$('.fileName').each(function(){
var img_names_input = $(img_names_input).val();
var img_names = $(this).html();
$(img_names_input).val(img_names_input+','+img_names);
});
</script>
This is working just fine, but it doesn't seem a perfect solution to me, I'm just a learner, anybody could come up with a better solution? something like:
$('.fileName').each(function(){
var img_names .= ',' + $(this).html();
alert(img_names);
});
or maybe some sort of array implementation here... !? Thanks