In my Javascript application, I receive a line of HTML code from an endpoint. I cannot change the HTML content that I receive from this endpoint. I want to convert the radio buttons into a regular button, and not sure how to go about rewriting this. The HTML I receive can have anything in it - I only want to replace the radio buttons.
Here's what I might be given as a string:
<form>
<input type="radio" name="a" value="1">Option 1
<br>
<input type="radio" name="a" value="2">Option 2
</form>
and I want to convert it to this string:
<form>
<input type="button" id="button-a-1" value="Option 1">
<br>
<input type="button" id="button-a-2" value="Option 2">
</form>
Here's how this is currently used:
$.post('url', data, function(resp) { $('#content').html(resp.html); });
I thought I could do this by find/replace type="radio" with type="button", but I'm not sure how to get the text after the input tag into a value tag by manipulating the string. And also get an id in there so I can tie an event handler to it.
Option 1part is what makes this a pain.... lol