CSS Relative/Absolute (Relative/absolute) positioning with jquery control display hidden

Source: Internet
Author: User

Previously written show hide is always controlled with the JQ method:

dom.show();dom.hide();

In fact, this still has a lot of flaws.
This is the HTML structure:

    <divclass="holi">        somewords    </div>    <divid="button">点击显示</div>

If you use Position:absolute and top-9999px control points to hide

        .holi{            width: 200px;            height: 200px;            border: 1px solid red;            position: absolute;            visibility: hidden;        }

This should be the way to use JQ to show him better.

        $(function(){            $(‘#button‘).click(function(){                $(‘.holi‘).css({                    ‘position‘:‘static‘,                })            })        })

If it is Position:absolute+visibility:hidden, the hidden words of control:

That

        .holi{            width: 200px;            height: 200px;            border: 1px solid red;            position: absolute;            visibility: hidden;        }

This should be done with the JQ control display:

        $(function(){            $(‘#button‘).click(function(){                $(‘.holi‘).css({                    ‘position‘:‘static‘,                    ‘visibility‘:‘visible‘                })            })        })

And of course show hide directly calls this method completely hidden.

Element hiding and display is very common in the implementation of page making and interactive effect, if you just use Display:none and display:block/inline to implement the explicit control of DOM elements, then you are out.

If you want the hidden content to be recognized by the secondary reading device, you cannot use Display:none and Visibility:hidden to hide the elements. You can use the hidden method of impersonation hiding, also known as usability concealment. ABSOLUTE+TOP:-9999PX: If you want to be completely hidden, you can use Display:none or Visibility:hidden.

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

CSS Relative/Absolute (Relative/absolute) positioning with jquery control display hidden

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.