超链接没有't在新选项卡中打开

hyperlink doesn't open in a new tab

本文关键字:选项 新选项 超链接      更新时间:2024-01-28

我重新设计了我的网站,我的超链接有问题。查看我的代码,我认为问题出在js 中

<li class="product aopc">
        <a class="product-link"></a>
        <div class="product-details mCustomScrollbar">
    <a target="_blank" href="my link in pdf"><i class="material-icons">picture_as_pdf</i></a>
    </li>

还有我js 的一部分

// handle click events
$container.on( 'click', '.product', function( event ) {
    var $this = $( this );
    event.preventDefault();
    // if not already open, do so
    if ( !$this.hasClass( 'open' ) ){
        var $openItem = $container.find( '.open' );
        // if any, close currently open items
        if ( $openItem.length ) {
            closeItem( $openItem );
        }
        openItem( $this );
    }
});

并且这个:$container.on('click','.close',function(event){event.stopPropagation();closeItem($(this).closest('.product'));});

function openItem( $item ) {
    var $image = $item.find( '.product-image' );
    $item.addClass( 'loading' ).spin( spinJsConfiguration );
    $image.attr( 'src', $image.data( 'src-large' ) );
    $item.imagesLoaded( function() {
        $item.spin( false ).removeClass( 'loading' ).addClass( 'open' );
        $container.addClass( 'item-open' ).isotope( 'reLayout' );
        $item.append( '<div class="close">&times;</div>' );
    });
}
function closeItem( $item ) {
    $item.removeClass( 'open' ).find( '.close' ).remove();
    $container.removeClass( 'item-open' ).isotope( 'reLayout' );
}
});

任何帮助都将不胜感激

由于点击处理程序的原因,链接无法工作。您的链接是li.product.的子链接

单击处理程序包含preventDefault()。删除它将使链接重新工作。

编辑:根据您的意见,更改以下内容:

$container.on( 'click', '.product', function( event ) {
    var $this = $( this );

收件人:

$container.on( 'click', '.product-link', function( event ) {
    var $this = $( this ).parent();

并且不要删除preventDefault()