href javascript 按钮未显示

href javascript button not showing

我正在 javascript 中实现共享功能。但是按钮link没有出现,我真的是一个初学者,研究了但是我找不到我错在哪里,按钮link就是没有出现,没有错误登录我的控制台。如果有人能帮助我,我真的很迷茫。我很感激。

在打开这个问题之前,我看到了所有与同一个问题相关的问题,但是none在我的案例中是成功的。

$(document).ready(function() {

function sharefbimage() {
    FB.init({ appId: `XXXXXX`, status: true, cookie: true });
    FB.ui(
    {
        method: `share`,
        name: 'Facebook Dialogs',
        href: $(location).attr('href'),
        link: 'https://developers.facebook.com/docs/dialogs/',
        picture: 'your image url',
        caption: 'Ishelf Book',
        description: 'your description'
    },
    function (response) {
        if (response && response.post_id) {
            alert('success');
        } else {
            alert('error');
        }
    }
)};
    $(".result").on("click", function() {
        
        var id = $(this).attr("data-linkId");
        var url = $(this).attr("href");

        if(!id) {
            alert("data-linkId attribute not found");
        }

        increaseLinkClicks(id, url);

        return false;
    });


    var grid = $(".imageResults");

    grid.on("layoutComplete", function() {
        $(".gridItem img").css("visibility", "visible");
    });

    grid.masonry({
        itemSelector: ".gridItem",
        columnWidth: 200,
        gutter: 5,
        isInitLayout: false
    });


    $("[data-fancybox]").fancybox({

        caption : function( instance, item ) {
            var caption = $(this).data('caption') || '';
            var siteUrl = $(this).data('siteurl') || '';
            var sharefbimage = $(this).data('siteurl') || '';

            if ( item.type === 'image' ) {
                caption = (caption.length ? caption + '<br />' : '')
                 + '<a href="' + item.src + '">View image</a><br>'
                 + '<a href="' + siteUrl + '">Visit page</a>';
                 + '<a href="' + sharefbimage + '">share</a>';
            }

            return caption;
        },
        afterShow : function( instance, item ) {
            increaseImageClicks(item.src);
        }


    });

试试这个。

  if ( item.type === 'image' ) {
                caption = (caption.length ? caption + '<br />' : '')
                 + '<a href="' + item.src + '">View image</a><br>'
                 + '<a href="' + siteUrl + '">Visit page</a><br>'
                 + '<a href="' + sharefbimage + '">Share</a>';
            }