Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/19.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函数_Javascript - Fatal编程技术网

更改javascript函数

更改javascript函数,javascript,Javascript,我在theme.js文件中有一个函数 $('.open_copy').click(function(){ var that = $(this); var copy = that.prev(); that.parents('.asset').find('.cover').click(); copy.css('opacity', 0).show(); if (copy.children('.copy_content'

我在theme.js文件中有一个函数

 $('.open_copy').click(function(){
        var that = $(this);
        var copy = that.prev();

        that.parents('.asset').find('.cover').click();
        copy.css('opacity', 0).show();
        if (copy.children('.copy_content').data('jsp')) {
            copy.children('.copy_content').data('jsp').destroy();
        }
        var height = copy.children('.copy_content').css({height: ''}).height();

        if (height < that.parents('.asset').height() - 37) {
            var top = (that.parents('.asset').height() - height)/2;
            top = top < 37 ? 37 : top;
            copy.children('.copy_content').css({'margin-top': top});
        } else {
            copy.children('.copy_content').css({'margin-top': '', height: that.parents('.asset').height() - 37}).jScrollPane();
        }

        if (!that.parents('.asset').find('.close_copy').length) {
            that.prev().append('<a href="#" class="close_copy">Close</a>');
        }

        copy.animate({ 'opacity' : 1 }, 500);

        that.fadeOut(500);
        return false;
    });

对。您可以删除代码设置的单击处理程序,然后使用相同的代码添加自己的处理程序,除了
1
=>
0.9
更改

要删除该代码的单击处理程序(以及所有其他处理程序),请使用:

…然后当然添加您自己的新
单击
处理程序

因此,总的来说,您需要这段代码(
脚本
标记之后,包括
主题.js
,因此这段代码在这段代码之后运行):


$('.open_copy')。off('click')。click(function(){/Javascript支持重写变量和方法。
导入Theme.JS文件后,应该声明一个覆盖JS脚本。
因此,您可以准确地复制/粘贴该函数,只需更改所需的值即可


请注意,由于该函数是一个事件绑定,您可能需要首先解除onclick事件的绑定。

您必须覆盖它。首先您必须解除click事件的绑定,然后用新值重写整个函数。谢谢TJ,现在的问题是不透明度变为0.9,然后又变回0。@BogdanS:奇怪,我没有看到任何不透明度代码中会导致这种情况的东西。
copy.animate({ 'opacity' : 1 }, 500);
$('.open_copy').off('click');
$('.open_copy').off('click').click(function(){ // <== Changed
    var that = $(this);
    var copy = that.prev();

    that.parents('.asset').find('.cover').click();
    copy.css('opacity', 0).show();
    if (copy.children('.copy_content').data('jsp')) {
        copy.children('.copy_content').data('jsp').destroy();
    }
    var height = copy.children('.copy_content').css({height: ''}).height();

    if (height < that.parents('.asset').height() - 37) {
        var top = (that.parents('.asset').height() - height)/2;
        top = top < 37 ? 37 : top;
        copy.children('.copy_content').css({'margin-top': top});
    } else {
        copy.children('.copy_content').css({'margin-top': '', height: that.parents('.asset').height() - 37}).jScrollPane();
    }

    if (!that.parents('.asset').find('.close_copy').length) {
        that.prev().append('<a href="#" class="close_copy">Close</a>');
    }

    copy.animate({ 'opacity' : 0.9 }, 500);  // <== Changed

    that.fadeOut(500);
    return false;
});