Suppose to have a tab with 3 choices ("home","dog",house"). My purpose is to get the current selected element Anyone can help me?
I do this:
var r=$('#tab_sezioni ul li');
But in this way I take all tag
Suppose to have a tab with 3 choices ("home","dog",house"). My purpose is to get the current selected element Anyone can help me?
I do this:
var r=$('#tab_sezioni ul li');
But in this way I take all tag
You could try using a class so you can tell which tab is selected.
For example when you click on a tab add class selected
.
$('#tab_sezioni ul li').click(function(){
$('#tab_sezioni ul li').removeClass('selected');
$(this).addClass('selected');
});
And then get only selected element
var r=$('#tab_sezioni ul li.selected');
Or if you want just the index
var index=$('#tab_sezioni ul li').index($('#tab_sezioni ul li.selected'));