Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/468.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/79.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript div on.click事件不';当我使用chrome手机版时,我无法工作_Javascript_Jquery_Css_Google Chrome - Fatal编程技术网

Javascript div on.click事件不';当我使用chrome手机版时,我无法工作

Javascript div on.click事件不';当我使用chrome手机版时,我无法工作,javascript,jquery,css,google-chrome,Javascript,Jquery,Css,Google Chrome,我在jquery中有以下div元素: this.$flipPages.find( '.box' ).on( 'click.flips', function( event ) { var $box = $(this), $boxClose = $( '<span class="box-close">close</span>' ), transitionProp = { speed

我在jquery中有以下div元素:

this.$flipPages.find( '.box' ).on( 'click.flips', function( event ) {

    var $box            = $(this),
    $boxClose       = $( '<span class="box-close">close</span>' ),
    transitionProp  = {
        speed           : 450,
        timingfunction  : 'linear'
    },
    $overlay        = $( '<div class="overlay">close</div>' ).css( {
                        'z-index'               : 9998,
                        '-webkit-transition'    : 'opacity ' + transitionProp.speed + 'ms ' + transitionProp.timingfunction,
                        '-moz-transition'       : 'opacity ' + transitionProp.speed + 'ms ' + transitionProp.timingfunction
                    } ).prependTo( $( 'body' ) ),
    prop            = {
        width   : $box.outerWidth(true),
        height  : $box.outerHeight(true),
        left    : $box.offset().left,
        top     : $box.offset().top
    },
    $placeholder    = $box.clone().css( {
        'position'          : 'absolute',
        'width'             : prop.width,
        'height'            : prop.height,
        'left'              : prop.left,
        'top'               : prop.top,
        'zIndex'            : 9999,
        'overflow-y'        : 'auto',
        '-webkit-transition': 'all ' + transitionProp.speed + 'ms ' + transitionProp.timingfunction,
        '-moz-transition': 'all ' + transitionProp.speed + 'ms ' + transitionProp.timingfunction
    } )
    .insertAfter( $overlay )
    .end()
    .append( $boxClose.on( 'click.flips', function( event ) {

        $overlay.css( 'opacity', 0 );

        $placeholder.children().hide().end().removeClass( 'box-expanded' ).css( {
            width           : _self.windowProp.width,
            height          : _self.windowProp.height,
            'overflow-y'    : 'hidden'
        } );

        setTimeout( function() {
            $placeholder.css( {
                left    : prop.left,
                top     : prop.top,
                width   : prop.width,
                height  : prop.height,
                '-webkit-transition'    : 'all ' + transitionProp.speed + 'ms ' + transitionProp.timingfunction,
                '-moz-transition'   : 'all ' + transitionProp.speed + 'ms ' + transitionProp.timingfunction
            });
        }, 0 );

        }) ).children().hide().end()
            .on( 'webkitTransitionEnd.flips transitionend.flips OTransitionEnd.flips', function( event ) {

            if( $( event.target ).hasClass( 'box-expanded' ) ) { // expanding

                $(this).css( {
                    width   : '100%',
                    height  : '100%',
                    '-webkit-transition' : 'none',
                    '-moz-transition' : 'none'
                } ).children().fadeIn();

            }
            else { // collapsing

                $overlay.remove();
                $(this).remove();

            }

    });

    setTimeout( function() {

        $overlay.css( {
            opacity : 1
        } );

        $placeholder.addClass( 'box-expanded' ).css( {
            left    : 0,
            top     : 0,
            width   : _self.windowProp.width,
            height  : _self.windowProp.height
        });

    }, 0 );

} );
this.$flipages.find('.box').on('click.flips',函数(事件){
var$box=$(此),
$boxClose=$('close'),
transitionProp={
速度:450,
计时功能:“线性”
},
$overlay=$('close')。css({
“z指数”:9998,
“-webkit transition”:“不透明度”+transitionProp.speed+“ms”+transitionProp.timingfunction,
'-moz transition':“不透明度”+transitionProp.speed+“毫秒”+transitionProp.timingfunction
})。prependTo($(“body”),
道具={
宽度:$box.外层宽度(真),
高度:$box.outerHeight(真),
左:$box.offset().left,
顶部:$box.offset().top
},
$placeholder=$box.clone().css({
'位置':'绝对',
“宽度”:prop.width,
“高度”:道具高度,
“左”:道具左,
“top”:prop.top,
“zIndex”:9999,
“溢出-y”:“自动”,
“-webkit transition”:“all”+transitionProp.speed+“ms”+transitionProp.timingfunction,
“-moz transition”:“all”+transitionProp.speed+“ms”+transitionProp.timing函数
} )
.insertAfter($overlay)
(完)
.append($boxClose.on)('click.flips',函数(事件){
$overlay.css('opacity',0);
$placeholder.children().hide().end().removeClass('box expanded').css({
宽度:_self.windowProp.width,
高度:_self.windowProp.height,
“溢出-y”:“隐藏”
} );
setTimeout(函数(){
$placeholder.css({
左:道具左,
托普:托普,托普,
宽度:道具宽度,
高度:道具高度,
“-webkit transition”:“all”+transitionProp.speed+“ms”+transitionProp.timingfunction,
“-moz transition”:“all”+transitionProp.speed+“ms”+transitionProp.timing函数
});
}, 0 );
})).children().hide().end()
.on('WebKittTransitionEnd.flips transitionend.flips transitionend.flips',函数(事件){
if($(event.target).hasClass('box expanded')){//expanding
$(this.css({
宽度:“100%”,
高度:“100%”,
“-webkit转换”:“无”,
“-moz转换”:“无”
}).children().fadeIn();
}
否则{//崩溃
$overlay.remove();
$(this.remove();
}
});
setTimeout(函数(){
$overlay.css({
不透明度:1
} );
$placeholder.addClass('box expanded').css({
左:0,,
排名:0,
宽度:_self.windowProp.width,
高度:_self.windowProp.height
});
}, 0 );
} );
这个.box是一个有内容的div,它是可点击的,尽管它在桌面和笔记本电脑版本的chrome中有效,但在移动chrome版本中不起作用。它适用于safari android版本。我使用Kinetic,听说在chrome for mobile上使用Kinetic时需要做一些调整

有没有任何理由这在chrome手机上不起作用

编辑:


我在这个功能中添加了一个警报,当我使用chrome桌面时,它会打印,如果我使用chrome mobile,它不会发出任何警报。它没有被调用。

这段代码可以使它在移动设备中工作。这是一个mobile中的mock the mouse事件

if(BrowserDetect.browser.indexOf("Chrome") != -1) {
    var fireOnThis = document.getElementById("idofelementtobeclicked");
    var evObj = document.createEvent('MouseEvents');
    evObj.initMouseEvent('click', true, true, window, 0, 0, 345, 7, 220, false, false, true, false, 0, null);
    fireOnThis.dispatchEvent(evObj);
    return true;
}

希望对您有所帮助

您正在搜索的是手机点击事件和台式机点击事件
这可能会奏效:

this.$flipPages.find( '.box' ).on( 'touchend click.flips', function( event ) {
   ...
});

您需要从onclick函数返回false才能使其工作。如果不起作用,请检查我的答案。它可能会工作在哪个功能我应该把这个?返回错误不起作用。你说return true,但你从来没有说我应该把这段代码放在哪里,怎么放,而你可能在这里遇到了一些问题,你需要提供更多的解释,而不仅仅是把这段代码扔到这里。它在做什么,清楚地说?它是如何使用的?