javascript - Selecting all elements -
It should be really simple, but I have a Javascript / jQuery rookie, so we go here:
< P> I can select a certain element with the following code var user = $ (".ui-selected .user-name"). Html ();
But if there are many elements with the above classes, then only the first value will be selected, which I would like to complete is a variable in which all the elements are different, such as: user1, user2, User3 ... etc. Any help would be greatly appreciated, thanks in advance!
You can use to get an array of values, then in a string, like :
var usersString = $ (".ui-selected .user-name"). Map (function () {return $ (this) .html (); // or this.inner html}). Get () Join (',');
Edit:.
Comments
Post a Comment