← Back to Index

.join()

Creates a string by concatenating the text content of each element, separated by a separator.

Examples

1. Join with separator

// <li>Apple</li><li>Banana</li>
const str = $('li').join(', ');

Result

"Apple, Banana"

2. Default separator

const str2 = $('li').join();

Result

"Apple,Banana"

Parameters

Parameter Type Description
separator string Optional. Specifies a string to separate each element's text. Default is ",".

Returns: String.