string을 잘못 사용했을때 발생한다.
var options = $(this).data('options').filter('[value="' + checkval + '"]');
와 같이 + 를 사용해서 변수와 string을 이어주자.
6
1
I'm getting the Uncaught SyntaxError: Unexpected string error in my JavaScript and I honestly can't figure out what's wrong with the code. I have looked at the similar questions, but I'm unable to find a solution. The error is coming in the line highlighted with an asterisk below.
$("#items1").change(function () {
if ($(this).data('options') === undefined) {
$(this).data('options', $('#items2 option').clone());
}
var checkval = $(this).val();
/* this line: */ var options = $(this).data('options').filter('[value='"+ checkval +"']');
$('#items2').html(options);
});
The code is taken from Use jQuery to change a second select list based on the first select list option
I've added the extra quotes around the checkval to get rid of another error, this might be the problem, but if I change it, the other error returns.
checkVal
looks like a string, no? – Sterling Archer Apr 10 '14 at 21:15