I thought I could split a string inside a jquery function using the JavaScript .split method. The code below stores string as “value1, value2, value3”.
If I try to split that string and then alert the item, nothing happens. Any ideas?
I have verified that string_sp is correct so I know the issue is with the split line.
$(document).ready(function(){
$('.link_pressed').click(function() {
var string_sp = $('select.s_box').val();
var box_str = string_sp.split(',');
alert(box_str[0]);
});
});
You have a syntax error (didn’t close the click function call). Try this: