jquery set an element to show and hide doesn't work one flash over

Source: Internet
Author: User

Speaking up, are not deep enough for HTML CSS to understand the pot.
The original label was written like this.

<p  class= "Weui-btn-area" >
<a class= "weui-btn weui-btn_primary" href= "id=" Add_friend "> Add to the Friends List </a>
</p>

This is originally hidden, want to click After, surfaced, after a period of time, eliminate

<div id= "Successtoast" style= "Display:none;" >
    <div class= "weui-mask_transparent" ></div>
    <div class= "Weui-toast" >
        <i Class = "Weui-icon-success-no-circle weui-icon_toast" ></i>
        <p id= "successtoastcontent" class= "Weui-toast" __content "></p>
    </div>
</div>

JS Code:

Click Add to Ball Friends List triggers
     $ (document). On ("click", "#add_friend", function () {
               //Send Ajax request to background
        var to_id = $ (' #to_id '). Val ();
       $.ajax ({
            type: "Get",
            URL: "/organize/myorganizerequest?toid=" +to_id,
            success:function (data) {
               Showcompletetoast ("Invite success, waiting for friends to reply.") ");
            },
            error:function (data) {
                alert (data);}}
    )

; function Showcompletetoast (content) {
        $ (' #successtoastContent '). HTML ("");
        $ (' #successtoastContent '). HTML (content);
        if ($ (' #successtoast '). CSS (' display ')!= ' none ') return
            ;

        $ (' #successtoast '). FadeIn (m);
        settimeout (function () {
            $ (' #successtoast '). fadeout (MB);
        }
    

As a result, a flash of wood has. Cannot reach the desired effect.

After looking for some, and found that the reason was actually here, and

<a class= "weui-btn weui-btn_primary" href= "id=" Add_friend "> Add to Club Friends List </a>

Bad is bad in this a tag, it clicks is to refresh the page Ah, of course, will affect our processing.
It's OK to change it to a button.

Be careful to use a variety of labels, do not mess,

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.