Zepto.js determine the visibility of elements and show or hide

Source: Internet
Author: User
Tags file upload visibility


Recently on the move end of the project, so much of the use of ' lightweight zepto.js, now the problem is, I need to show-hide a div, generally to determine whether this div is visible, then show or hide, test a page is visible or invisible, generally use $ (' div '). Is (: Visible), however Zepto.js does not support: visible, so it must be judged in a different way:

(1) can check the CSS properties of the display: CSS ("display") = = "Block"

(2) can check visible: visible/Hidden: CSS ("visibility") = = "visible"

Examples are as follows:

Evaluation Hide-Show
$ ('. Comment-btn '). Click (function () {
if ($ ('. Hidecomment '). CSS ("display") = = "None") {

$ ('. Hidecomment '). Show ();
$ ('. Btnarrow '). Removeclass (' btnarrowtop ');
$ ('. Btnarrow '). addclass (' Btnarrowdown ');
}else if ($ ('. Hidecomment '). CSS ("display") = = "Block") {

$ ('. Hidecomment '). Hide ();
$ ('. Btnarrow '). addclass (' btnarrowtop ');
$ ('. Btnarrow '). Removeclass (' Btnarrowdown ');
}

});

In a mobile-end project, there are many things that are different from computer pages,

One, such as tap () and click () (300ms latency problem on mobile phone click events)

Second, such as: when the user finger on the mobile device on the screen sliding will trigger the touch event, Touchstart (), Touchmove (), Touchend () and so on.

Third, about the file upload control <input type= "File" > Accept properties:

<!– Select photos –>
<input type=file accept= "image/*" >
<!– Select Video –>
<input type=file accept= "video/*" >

Four, Android users click on a link, there will be a border or translucent gray mask, different manufacturers to define the amount of the effect is not the same, you can set the-webkit-tap-highlight-color alpha value of 0 to remove some of the machine from the effect of the band

a{
-webkit-tap-highlight-color:rgba (0,0,0,0);
Outline:none;
Text-decoration:none;
}

Five, our common select control under the iOS system, with the rolling effect, and the Android system does not have that effect

VI, the use of jquery is really convenient, such as to control the display of div and hide, a word is done, please see the following instructions.
$ ("#id"). Show () indicates Display:block,
$ ("#id"). Hide () indicates display:none;
$ ("#id"). Toggle () Toggles the visible state of the element. If the element is visible, switch to hidden, and if the element is hidden, toggle to visible.

$ ("#id"). CSS (' Display ', ' none ');
$ ("#id"). CSS (' Display ', ' block ');
Or
$ ("#id") [0].style.display = ' none ';

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.