У меня есть букмарклет, который добавляет фиксированный div на страницу и должен переключаться между фреймами, когда я нажимаю на определенные кнопки c. Я использую jQuery для активации кнопки, но она не работает.
вот код для добавления jQuery:
var x = document.createElement('script');
x.src = 'https://code.jquery.com/jquery-3.4.1.js';
document.body.appendChild(x);
вот код, добавляющий div:
var lol = document.createElement('div');
lol.id = "desmos";
lol.style.background = 'blue';
lol.style.position = 'fixed';
lol.style.width = '30%';
lol.style.height = '50%';
lol.style.top = '40%';
lol.style.left = '70%';
lol.innerHTML = "<style>body{color: white;}</style>toggle iframes <button id='button'>1</button> <button id='button2'>2</button> <button id='button3'>3</button> <iframe id='iframe' src='https://desmos.com/calculator'></iframe> <iframe id='iframe2' src='https://desmos.com/scientific'></iframe> <iframe id='iframe3' src='https://desmos.com/geometry'></iframe>";
document.body.appendChild(lol);
, а вот код, который использует jQuery для переключения между фреймами:
$("#iframe").hide();
$("#iframe2").hide();
$("#button").click(function() {
$("#iframe").show();
$("#iframe2").hide();
$("#iframe3").hide();
});
$("#button2").click(function() {
$("#iframe2").show();
$("#iframe").hide();
$("#iframe3").hide();
});
$("#button3").click(function() {
$("#iframe3").show();
$("#iframe2").hide();
$("#iframe").hide();
});