The problem here is not how you call yea
, it is everything around it.
This would be fine:
append( some_string + yea() + some_string );
… but where you should have strings (which could be string literals or variables or any other JavaScript expression), you have raw HTML, which isn’t allowed.
You seem to have missed the '
off from the start of the first string, and the other '
from the end of the second string, and inserted a raw new line in the middle of both (which is forbidden).
$(wrapper).append(
'<div class="form-group"><select name="from_year[]" class ="form-control"> ' + yea() + ' </select></div>'
);
solved How do I call my function in Javascript? [closed]