fiddle: https://jsfiddle.net/jzhang172/4ntjykr0/
var x="pokemon,rykrkr";
x.split(",");
document.getElementById('ok').innerHTML=x[0];
<div id="ok"></div>
Isn't this supposed to show the whole word "pokemon" because I specified that it would split on comma?
.split doesn't alter the original string, so you have to do it like this:
var x = "pokemon,rykrkr";
var splited = x.split(",");
document.getElementById('ok').innerHTML = splited[0];
<div id="ok"></div>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With