do something if element hidden

This question already has an answer here:

  • How do I check if an element is hidden in jQuery? 53 answers

  • try something like this

    if($('#testElement').is(':visible')){
       //what you want to do when is visible
    }
    

    for your code

    if($('input[name="firstname"], input[name="lastname"]').is(':visible')){
      $('input[name="fullname"]').hide();
    }
    

    REFERENCE

    http://api.jquery.com/visible-selector/


    you should change

    <input type="text" name="fullname"> 
    to 
    <input type="hidden" name="fullname">
    

    to make an input field hidden


    这应该工作$(element).is(":visible")

    链接地址: http://www.djcxy.com/p/2396.html

    上一篇: 如何检查一个元素是否隐藏了jquery

    下一篇: 如果元素隐藏,做些事情