Reputation: 63
I have tried
var currentVis = $("div:visible");
alert(currentVis);
If the div in question is like: <div id="DIVONE">
I want var currentVis
to alert DIVONE
. All I get is object object
.
Upvotes: 0
Views: 771
Reputation: 1012
$("div:visible").each(function(){
if($(this).attr("id")=="DIVONE"){
//do somethings
}});
Upvotes: 0
Reputation: 22817
If your selector finds a div, just refer to its id via:
currentVis[0].id
Upvotes: 1
Reputation: 1073
var currentVis = $("div:visible");
var id = currentVis.attr('id');
Upvotes: 1
Reputation: 94309
var currentVis = $("div:visible");
alert(currentVis[0].id);
-or-
alert(currentVis.attr("id"));
Upvotes: 3