I have a button where on clicking the button it will clear all the textbox and drop down values now i need to create a common function and place my below jquery code in that common function so that i can call that function in button2,button3 click events of jquery
<input type="button" value="Clear" title="clear" id="btnclear" />
<input type="button" value="" title="clear" id="btn2" />
<input type="button" value="" title="clear" id="btn3" />
function clear_text() //this is my common function
{
$('#txtname').val("");
}
$('#btnclear').off('click').on('click', function (RD) {
clear_text(); //calling the common function
});
$("#btn2").click(function () {
if ($(this).hasClass("buttonActive")) {
$("#tr1").show();
$("#tr2").show();
}
else {
clear_text(); //while hiding i am clearing the text in the fields
$("#tr1").hide();
$("#tr2").hide();
}
});
$("#btn3").click(function () {
if ($(this).hasClass("buttonActive")) {
$("#tr1").show();
$("#tr2").show();
}
else {
clear_text(); //while hiding i am clearing the text in the fields
$("#tr1").hide();
$("#tr2").hide();
}
});