1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
|
function show(title) { let currentMenu = document.getElementById(title); let currentStatus = currentMenu.style.display; currentMenu.style.display = currentStatus == "" ? "none" : ""; }
function showImg() { let fruit = document.getElementById('fruit'); let fruitSrc = fruit.getAttribute('src'); let msg1 = document.getElementById('msg1'); msg1.innerHTML = fruitSrc; }
function getFruit() { let enjoyList = document.getElementsByName("enjoy"); let chooseList = []; for (let index in enjoyList) { if (enjoyList[index].checked) { chooseList.push(enjoyList[index].value); } } let msg2 = document.getElementById("msg2"); msg2.innerHTML = '你喜欢的水果是:' + chooseList.toString(); }
let checkImg = false;
function createImg() { if (checkImg) { return; } let img = document.createElement('img'); img.src = './work02/grape.jpg'; let station = document.getElementById('msg3'); station.appendChild(img);
checkImg = true; }
let imgCloned = false;
function cloneImg() { if (imgCloned) { return; } let fruit = document.getElementById('fruit'); let cloneImg = fruit.cloneNode(true); let msg4 = document.getElementById('msg4'); msg4.appendChild(cloneImg);
imgCloned = true; }
function changeImg() { let imgSrc = './work02/grape.jpg'; let fruit = document.getElementById('fruit'); fruit.src = imgSrc; }
function removeImg() { let img = document.getElementById('fruit'); let parentElement = img.parentNode; if (parentElement) { parentElement.removeChild(img); } }
function changeCss1() { let fruit = document.getElementById('fruit'); fruit.style.border = '2px solid red'; }
function changeCss2() { let fieldsetList = document.getElementsByTagName('fieldset'); for (let fieldset of fieldsetList) { fieldset.className = 'newcss1'; } }
|