HTML / JS:困惑的方法来创建一个图像按钮 [英] HTML/JS: Confused about method to create an image button
问题描述
我只需要创建的图像的制成一个简单的按钮,并且当用户点击它,这将开启一个JQuery的对话框。
I need to create a simple button made only of an image, and which will open a JQuery Dialog when the user clicks on it.
我做一些阅读,并注意许多解决方案:<按钮>
,<图像>
带< A>
,使用CSS来修改按钮的背景,等等...
I am doing some reading and notice many solutions: <button>
, <image>
with a <a>
, using CSS to modify a button background, etc...
这是混乱的,什么是我实现图像按钮的正确方法?
This is confusing, what is the proper way to implement my image button?
感谢。
P.S:按钮/形象应该是focussable。一个操作的jsfiddle例子是值得欢迎的。
P.S.: The button/image should be focussable. An operational JSFiddle example is welcome.
推荐答案
我找到了很多解决方案后的斗争:的http://的jsfiddle。净/ YRY8M / 3 / 。
I found the solution after many struggles: http://jsfiddle.net/YRY8M/3/.
<html>
<head></head>
<body>
<input type="image" tabindex="0" onclick="doSomething()" src="http://upload.wikimedia.org/wikipedia/commons/thumb/0/0c/White_and_yellow_flower.JPG/320px-White_and_yellow_flower.JPG"
/>
<br />
<button tabindex="1">I am focussable too !!!</button>
</body>
</html>
和一些javascript:
And some javascript:
function doSomething() {
alert('Hello!');
}
这篇关于HTML / JS:困惑的方法来创建一个图像按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!