使用JQuery将单选按钮替换为图像 [英] Replace radio buttons with images using JQuery

查看:108
本文介绍了使用JQuery将单选按钮替换为图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一组单选按钮,我想在选中和取消选中时替换为图像。

I have group of radio buttons which I want to replace with images when checked and unchecked.

<div id="answerOptions">
<input type="radio" name="answeroption" id="r1" value="radio1" checked=''checked'/>radio1<br/>
<input type="radio" name="answeroption" id="r2" value="radio2"/>radio2<br/>
</div>

我有两张图片1. button_on.JPG用于选中单选按钮而2. button_off.JPG表示没有选中单选按钮。
我想完成以下任务
1.我想用这些图像替换单选按钮。
2.加载页面时,选中的单选按钮应该有正确的图像。

I have two images 1. button_on.JPG for checked radio button and 2. button_off.JPG for not checked radio button. I want to accomplish following tasks 1. I want to replace radio buttons with these images. 2. On load of the page checked radio button should have correct image.

注意:单选按钮是动态生成的,它们的ID和值都会发生变化在每个请求上。

Note: Radio buttons are generated dynamically and their ids as well as value do change on each request.

我需要使用Jquery的帮助。赞赏你的输入。

I need the help using Jquery. Appritiate your inputs.

推荐答案

不要重新发明轮子,为此使用一个漂亮的库:

Don't reinvent the wheel, use a nice library for this:

http://uniformjs.com/

这篇关于使用JQuery将单选按钮替换为图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆