Skip to content
Advertisement

Jquery removing commas

I’m using the following and it works, but the alerted value opt3 contains commas.

How do I remove them?

JavaScript

If I select a c & d the alert shows a,c,d but I want it to show acd.

Advertisement

Answer

What about this?

JavaScript

Update:

Ok. Like @jreziga mentioned. The return value of .val() will be an array. If you have a string the upper code example will do just fine. If you have an array like in your case you can do this:

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement