0

I am trying to run a function if is visible and not allow it to run if is visible. My code is the following but it does not work. The function runs fine.

function onAnyChange(){
  if ($('#text_side_content_submit').css('display') != 'none'){
  ...do something...
  }
}

What I would like is to use something like:

.css('display') == 'visible')

but "display" does not have such a property. Based on the manual the default value of "display" is "inline", but that breaks the code. What should I use?

  • 5
    I think you're looking for this http://stackoverflow.com/questions/15924751/check-if-a-element-is-displaynone-or-block-on-click-jquery – Kevin Oct 25 '16 at 19:13
  • Exactly what I was looking for. Thanks –  Oct 25 '16 at 19:17

1 Answers1

0

JQuery has :visible and :hidden selector. Use these selectors.

if($('#text_side_content_submit:hidden').length == 0){
// do something
selami
  • 2,478
  • 1
  • 21
  • 25