2
I have the following code inside a javascript function that is inside a page . php:
if (indice_da_aba == -1)
{
window.alert('não existe ABAS AINDA');
}
else
if (indice_da_aba == 0)
{
$('a[href="#tab_00"]').tab('show');
}
else
if (indice_da_aba == 1)
{
$('a[href="#tab_01"]').tab('show');
}
else
if (indice_da_aba == 2)
{
$('a[href="#tab_02"]').tab('show');
}
As you can see there are many if
s.
I wonder if it is possible to write a if
as follows:
if (indice_da_aba == -1)
{
window.alert('não existe ABAS AINDA');
}
else
{
$('a[href="#tab_0+indice_da_aba+"]').tab('show');
}
The way I wrote it doesn’t work. There would be a sure way to write (concatenate) that line or it’s not possible?
I couldn’t use
$('a[href="#tab_0'+indice_da_aba+'"]')
? What I think you’re missing is the closes and opens parenthesis to concatenate the variable.– Gustavo Cinque