Frage

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.

War es hilfreich?

Lösung

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");
});

Andere Tipps

try below code :-

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

Demo :-

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

Try this code:

if(!$("#your_label_id").is(":visible"))
   $("#remove_class").removeClass("class_name");

try this:

if($("#lblid").css("display")==='none'){
    $("#lblid").removeClass("hidden");//or $("#lblid").css("display","block")
}

use this code:

if($('label').is(':visible'))
{
  // remove hidden class
 $('.disp-block').removeClass('hidden');
}
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top