How to use variable value in jquery

1

I'm having trouble using the value inside my variable when I use jquery

var id_pais =  $('#endUF option[value=id_pais]').text();
        $('#endUF option[value=id_pais]').remove();
        $('#endPAIS option[value=id_pais]').prop('selected', true);

In case I get the value of my system and put it in a variable js. But then I can not reuse it in jquery. I've read about it and saw that when I use value in jquery, like the one used above, jquery sees it as a string and does not take the value of the variable.

    
asked by anonymous 08.08.2015 / 18:03

1 answer

1

Missing concatenate variable. Try the following:

var id_pais =  $('#endUF option[value=' + id_pais + ']').text();
        $('#endUF option[value=' + id_pais + ']').remove();
        $('#endPAIS option[value=' + id_pais + ']').prop('selected', true);
    
08.08.2015 / 19:49