I'm adding Radio button dynamically
function RadioButton() {
$.ajax({
type: "POST",
url: "VPATransaction.aspx/SetRadioButton",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
async: false,
success: function (result) {
var jsonData = eval(result.d);
$.each(result.d.Table, function (index, value) {
$('#rb').append("<ul><li><input type='radio' name='radio' id='rbs_' value=" + value.PurposeTransid + " style><span id='tf' name='TextFiled'>" + value.Purpose_trans_name + " </span></li></ul>");
$("#rbs_").click(function () {
$("#tf0").val("");
});
});
}
})
}
**TextBox is also adding dynamically**
function Textbox() {
$("#add")
.append($(" <div class='col-md-12'>")
.append($(" <input type='text' name='TextField' id='TF" + Tcount + "'class='col-sm-12 col-md-12 col-xs-12' />")
.append($("</div>")
)
)
);
Tcount++;
}
because on button click I'm adding more textBox
Goal is to clear value of textbox when i click on other radio button I have used .val and .attr but nothing happend
Here you did not use the click function while using the textbox dynamic function. So you can use like following method,
$(document).ready(RadioButton(){
$('#btnClear').click(RadioButton(){
if(confirm("Want to clear?")){
$('#form1 input[type="text"]').val('');
$('#form1 #txtAddress').val('');
Here when you click the Radio button the function will automatically clear the text box after you click yes on the dialog box appears.