最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - HTML Radio buttons styled as Toggle Buttons - Stack Overflow

programmeradmin4浏览0评论

Instead of having the typical disks with labels to the right, I want the options to be presented as clickable buttons. The selected option should appear to be pushed or pressed in.

I want to do this in HTML, but an example of this are the top left buttons in the program Audacity where you select the cursor/tool mode.

What's the best way to do this?


(source: freemusicsoftware.info)

Instead of having the typical disks with labels to the right, I want the options to be presented as clickable buttons. The selected option should appear to be pushed or pressed in.

I want to do this in HTML, but an example of this are the top left buttons in the program Audacity where you select the cursor/tool mode.

What's the best way to do this?


(source: freemusicsoftware.info)

Share Improve this question edited Mar 4, 2019 at 2:00 Glorfindel 22.7k13 gold badges90 silver badges119 bronze badges asked Feb 26, 2009 at 22:12 LarsenalLarsenal 51.3k43 gold badges154 silver badges224 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 6

There are a number of JavaScript plugins for doing this:

  • Prototype demo

Just replace the images they're using with your images and you should be good to go.

Probably the best way is to create a real radio button, and then control the rendering of an element based upon the status on the radio button with javascript. If the radio button is selected, render background-a, else background-b (or use a sprite). Control the status of the radio button via the click event of your custom element.

Using this jQuery UI plugin, you can customize radio buttons and/or checkboxes to look however you want.

发布评论

评论列表(0)

  1. 暂无评论