S
S
SideWest2019-11-03 00:50:45
JavaScript
SideWest, 2019-11-03 00:50:45

How to make jQuery work without refresh?

Start to deal with jquery, write my own little chrome

extension

$(document).ready(()=>{
    // if (!window.location.href.includes('vk')) return;
    let pers_id = $("#profile_photo_link").attr("href").split('/photo')[1].split('_')[0];
    $(".page_name").hover(() => {
        $(".page_name").append(`<div class="meow"><b>  ${pers_id} </b></div>`);
        $(".meow").css({
            fontSize: 14
        });

    }, () => {
        $(".meow").remove()
    });
});


Everything would be fine, but VK, as I understand it, is written in react, which means it doesn’t reload, that is, when you scroll to another user, the script stops working until you reload the page manually, tell me what to do?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
X
xmoonlight, 2019-11-03
@SideWest

// Setup our function to run on various events
var someFunction = function (event) {
    // Do something...
};

// Add our event listeners
document.addEventListener('DOMContentLoaded', someFunction, false);
document.addEventListener('click', someFunction, false);

or like this:
"DOMContentLoaded click".split(" ").forEach(function(e){
      document.addEventListener(e,someFunction,false);
    });

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question