Search code examples
jquerydynamicsyntaxsingle-quotes

Writing variable to single quote in jquery


I tried a lot but I couldn't solve this poroblem. My aim write a variable in single quote to set dynamic active but when I want to do it I get syntax errors.

$('#tabs a[href="#vtab" + result.step_next + ]').tab('show');

Solution

  • Moving my comment to an answer

    You aren't concatenating the string properly. Try:

    $('#tabs a[href="#vtab' + result.step_next + '"]').tab('show');
    

    It appears to work here.