Use Array.join
var s = "";
n.each(function() {
s += $(this).val() + ",";
});
becomes:
var a = [];
n.each(function() {
a.push($(this).val());
});
var s = a.join(', ');
More Related Contents:
- Difference between .ajaxSubmit() vs .submit()
- Check if a user has scrolled to the bottom (not just the window, but any element) [duplicate]
- Check if an array is empty or exists
- How do you log all events fired by an element in jQuery?
- Deprecation warning in Moment.js – Not in a recognized ISO format
- How to trigger ngClick programmatically
- Convert JS Object to form data
- When should I use return false in jquery function?
- Why cache jQuery objects?
- Bootstrap 4 File Input
- HTML anchor link – href and onclick both?
- How can I differentiate a manual scroll (via mousewheel/scrollbar) from a Javascript/jQuery scroll?
- What is the elegant way to get the latest date from array of objects in client side?
- Read :hover pseudo class with javascript
- How to set the first option on a select box using jQuery?
- jQuery find and replace string
- Problem with jQuery.ajax with ‘delete’ method in ie
- How to reset all checkboxes using jQuery or pure JS?
- How to stop refreshing page after ajax call?
- Difference between $(“#id”).load and $.ajax?
- jQuery text() and newlines
- jQuery if statement with variable mathematical operator [duplicate]
- Callback function for JSONP with jQuery AJAX
- How can I return a view from an AJAX call in Laravel 5?
- Javascript Equivalent to C# LINQ Select
- Generate Random Color distinguishable to Humans
- How to get the width of an svg:g element
- Iframe inherit from parent
- Is it a bad practice to use jQuery in Angular? [closed]
- trigger file upload dialog using javascript/jquery