简体   繁体   中英

Wrap button in <a> using javascript

Is there any way to do it? via javascript, i created a input="image" and I want to wrap it in an <a> , so when I click it, a modal will pop up.

 function amphi() {
     amp.setAttribute('type', 'image');
     amp.setAttribute('src', 'baloon.png');
     amp.setAttribute('style', 'position:absolute; left:540px; top:312px; color:red;');
     amp.setAttribute('title', 'Amphitheater');
     amp.setAttribute('ondblclick', 'confirm(`Amphitheater:\n \n \nLorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.`);');

     document.body.appendChild(amp);
     hidethis();
     amp.style.visibility = "visible";
 }

Is this what you are looking for?

HTML

<img src="yourbuttonimage.png" onclick="popModal()" />

JS

function popModal(){
    //your modal instantiation script here
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM