我如何...替换radiobutton。 [英] How do I..replace radiobutton.

查看:76
本文介绍了我如何...替换radiobutton。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好先生hw ru!

i希望通过点击一个按钮替换radiobutton text permenentaly dynamicaly。

例如我想改变从中取出的radiobutton文本textfield然后当我重新启动项目时,对radiobutton的更改不存在。



所以请给出简单的例子,用代码替换radiobutton文本或作为整体radiobutton由另一个单击按钮即可完成单选按钮。

感谢提前

解决方案

您应该将文本包装在<   label  > 元素:

< div id = TheOptions >
< 输入 类型 = radio id = test1 name = mylist / > < label for = test1 > 选项1 < / label >
< input type = radio id = test2 name = mylist / > < label = test1 > 选项2 < / label >
< 输入 type = < span class =code-keyword> radio id = test3 姓名 = mylist / > < label < span class =code-attribute> for = test1 > 选项3 < / label >
< 输入 type = radio id = test4 name = mylist / > < label for = test1 > 选项4 & / label >
< / div >
< 输入 类型 = 按钮 id = btnChnage / >

现在,您的文字与相应的单选按钮明确关联,用户将即使能够点击文字,视障用户也会非常感谢提高可用性。然后你可以这样做:


(document).ready(function(){


('#btnChange')。click(function() {

hello sir hw r u!
i want to replace the radiobutton text permenentaly dynamicaly by clicking a button.
for example i want to change the text of radiobutton taken from the textfield and then when i relaunche the project the change to the radiobutton doesnot exist.

so kindly give simple example with code that replace radiobutton text or as a whole radiobutton by another radiobutton by clicking a button.
thank n advance

解决方案

You should wrap your text in <label> elements:

<div id="TheOptions">
  <input type="radio" id="test1" name="mylist"/><label for="test1">option 1</label>
  <input type="radio" id="test2" name="mylist"/><label for="test1">option 2</label>
  <input type="radio" id="test3" name="mylist"/><label for="test1">option 3</label>
  <input type="radio" id="test4" name="mylist"/><label for="test1">option 4</label>
</div>
<input type="button" id="btnChnage"/>

Now your text is explicitly associated with the corresponding radio button and users will even be able to click on the text, visually impaired users will also be quite thankful for the improved usability. Then you can just do:


(document).ready(function(){


('#btnChange').click(function(){


这篇关于我如何...替换radiobutton。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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