1

I'm using below css to hide an element :

.pds-pd-link {     
    display: none !important; 
} 

Using jQuery can I enable the display on the css .pds-pd-link

Something like $(.pds-pd-link).css("display",""); ?

Anish Gupta
  • 2,218
  • 2
  • 23
  • 37
blue-sky
  • 51,962
  • 152
  • 427
  • 752

3 Answers3

2

In a nutshell, yes.

Alternatively, you could use the following to show or hide the element:

$(.pds-pd-link).show();
$(.pds-pd-link).hide();

Or you could even use the toggle method to automatically switch between the two:

$(.pds-pd-link).toggle();
Richard
  • 8,110
  • 3
  • 36
  • 59
  • 1
    As a side note: toggle does not perfom as well and is about 3-4 times slower than show/hide and even close to 10 times slower in IE. See here for more details: http://www.learningjquery.com/2010/05/now-you-see-me-showhide-performance – Nope Jun 29 '12 at 16:25
0

Although you could do:

$(.pds-pd-link).css("display","none");

I would suggest:

$(.pds-pd-link).hide();
Mike Mackintosh
  • 13,917
  • 6
  • 60
  • 87
  • why suggest one over the other ? – blue-sky Jun 29 '12 at 16:08
  • 1
    `.hide` uses `dispaly: none`. Using `.hide()` makes for shorter, cleaner and more readable code at no extra cost. Same goes for `.show()` which uses `.css('display', 'xxx')`. where xxx is what ever the display property was initially. If it was not set `block` is used by default. – Nope Jun 29 '12 at 16:21
  • Agreed, just wanted to correct the OP's original syntax on the use of `.css('display', '...');` – Mike Mackintosh Jun 29 '12 at 16:24
-3

This should work

$('.pds-pd-link').css('cssText', 'display: block !important');
Artur Michalak
  • 459
  • 3
  • 6