简体   繁体   English

jQuery的。 单击后如何删除按钮?

[英]jQuery. How to remove button after It is clicked?

How to remove Facebook like button after It is clicked (with jQuery)? 单击它后如何删除Facebook之类的按钮(使用jQuery)?

This is my code. 这是我的代码。 After Like button is clicked It alert "I just clicked like button", but this line not working $(this).remove(); 单击Like按钮后它会提醒“我只是点击了按钮”,但这行不起作用$(this).remove(); . How to remove It? 如何删除它?

  <div id="fb-root"></div>
    <script>
    window.fbAsyncInit = function(e) {
        FB.Event.subscribe('edge.create', function(response) {
             $(this).remove(); // I used this to remove button after clicking, but not working
             alert('I just clicked like button');
        });
    };

    (function(d, s, id) {
        var js, fjs = d.getElementsByTagName(s)[0];
        if(d.getElementById(id)){return;}
        js = d.createElement(s);
        js.id = id;
        js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
        fjs.parentNode.insertBefore(js, fjs);
    }(document, 'script', 'facebook-jssdk'));
    </script>

And this is my FB Like button: 这是我的FB Like按钮:

<div class="fb-like" data-href="https://facebook.com/myPage" data-layout="button" data-action="like" data-show-faces="false" data-share="false" ></div>

Replace $(this).remove() with $(this).remove()替换$(this).remove()

$( ".fb-like" ).remove();

It will remove the element with the fb-like class. 它将使用fb-like类删除元素。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM