图像充当按钮HTML

时间:2015-02-17 14:40:16

标签: javascript jquery html image button

您好,我有这段代码:

 <!-- Button that triggers the popup -->
            <button id="my-button">POP IT UP</button>
            <!-- Element to pop up -->
            <div id="element_to_pop_up">Content of popup</div>

我有这个形象:

<img src="botones/bannerdiseno_audifonosinpilas.png" width="160" height="33"  alt=""/>
</a><a href="tecnologia.html">

我想知道如何更改该图像上的链接以执行与按钮相同的操作,我应该使用哪种语法,因此每当我单击图像时它会触发按钮操作并删除按钮本身< / p>

由于

2 个答案:

答案 0 :(得分:0)

您可以使用input type="image"

<input type="image" src="submit.gif" alt="Submit">

答案 1 :(得分:0)

    <img onclick="document.getElementById('my-button').click()" src="botones/bannerdiseno_audifonosinpilas.png" width="160" height="33"  alt=""/>

or 

<a href="javascript: document.getElementById('my-button').click()"> <img src="botones/bannerdiseno_audifonosinpilas.png" width="160" height="33"  alt=""/></a>