Detect label display, remove class hidden
Asked Answered
M

5

6

I want to detect if a label's display is none. If it is, then I'll remove the hidden class from the label.

How can this be done in jQuery? I'm new with js & jQuery.

Monochromat answered 8/5, 2014 at 6:3 Comment(4)
What have u tried so far?Kaspar
Did you google.co.in/search?q=jquery+check+if+element+is+hiddenContumacious
$(function () { if($(label).css('display') === 'none'){ $('.disp-block').removeClass("hidden"); } }); I've tried this but I don't know if my syntax is correctMonochromat
instead of $('.disp-block') use $(label) hereKaspar
G
6

You can follow below code

if(!$("label").is(":visible"))
{
  // remove hidden class
  $("label").removeClass("hidden");
}

but if you have multiple labels in your code then try below

$("label").each(function(){
  if($(this).is(":visible"))
     $(this).removeClass("hidden");
});
Griddlecake answered 8/5, 2014 at 6:5 Comment(0)
M
2

try below code :-

if($("#labelID").is(":visible"))
{
  // remove hidden class
  $("#labelID").removeClass("hidden");
}

Demo :-

http://jsfiddle.net/avmCX/45/

Middy answered 8/5, 2014 at 6:9 Comment(1)
how will you get this instance here?Griddlecake
V
1

Try this code:

if(!$("#your_label_id").is(":visible"))
   $("#remove_class").removeClass("class_name");
Vampire answered 8/5, 2014 at 6:6 Comment(0)
K
1

try this:

if($("#lblid").css("display")==='none'){
    $("#lblid").removeClass("hidden");//or $("#lblid").css("display","block")
}
Kaspar answered 8/5, 2014 at 6:11 Comment(0)
M
1

use this code:

if($('label').is(':visible'))
{
  // remove hidden class
 $('.disp-block').removeClass('hidden');
}
Mayotte answered 8/5, 2014 at 6:11 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.