Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/75.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 addEventListener';存储';在jquery中_Javascript_Jquery_Addeventlistener - Fatal编程技术网

javascript addEventListener';存储';在jquery中

javascript addEventListener';存储';在jquery中,javascript,jquery,addeventlistener,Javascript,Jquery,Addeventlistener,这个javascript addEventListener的等价物是什么 function displayStorageEvent(e) { if (e.key == 'storage-event') { output.innerHTML = localStorage.getItem("storage-event"); } } window.addEventListener("storage", displayStorageEvent, true); 要Jque

这个javascript addEventListener的等价物是什么

function displayStorageEvent(e) {
    if (e.key == 'storage-event') {
        output.innerHTML = localStorage.getItem("storage-event");
    }
}
window.addEventListener("storage", displayStorageEvent, true);
Jquery?我一直试图将它与.bind()一起使用,但它不知道“storage”关键字。我用这个试过了,但是“e”没有定义

$(document).ready(function(){
    displayStorageEvent();
});

谢谢

我想我明白了。我没有意识到我忽略了一些信息

$(document).ready(function(){
    $("#mybutton").bind("click", function(){
        updateStorageEvent();
        $("#mydiv").html(localStorage.getItem("storage-event"));
    });

    $(window).bind("storage",function(e){
        $("#mydiv").html(localStorage.getItem("storage-event"));
    });

});

您如何使用
.bind
?签出: