Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
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
Posted

1 solution

XML
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(){
$('label[for=test1]').html('best option');

});

});
 
Share this answer
 
Comments
wajib rehman 12-Jun-15 14:14pm    
i want in android not in html

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900