Hello, I have some working JS code on my website that shows/hides DIVs.
The line I'm interested in is:
What this line does is reset all form values in the shape of <input> fields.
At the same time I would like that line to reset all form values in the shape of <select> fields as well.
I have tried
But that doesn't work.
Rather than going in circles (my JS and syntax related knowledge is WEAK) I thought I'd post it here and see if anybody can help.
Thanks
Code:
function show1() {
var div_num = $("#choosediv").val();
if (div_num == 0) {
$("#div1").hide();
$("#div2").hide();
$(':input', '#div1').each(function () {
this.value = '';
});
$(':input', '#div2').each(function () {
this.value = '';
});
};
if (div_num == 1) {
$("#div2").hide();
$("#div1").show();
$(':input', '#div2').each(function () {
this.value = '';
});
};
if (div_num == 2) {
$("#div2").show();
$("#div1").hide();
$(':input', '#div1').each(function () {
this.value = '';
});
};
}
The line I'm interested in is:
Code:
$(':input', '#div1').each(function () {
this.value = '';
What this line does is reset all form values in the shape of <input> fields.
At the same time I would like that line to reset all form values in the shape of <select> fields as well.
I have tried
Code:
$(':input', ':select', '#div2').each(function () {
this.value = '';
But that doesn't work.
Rather than going in circles (my JS and syntax related knowledge is WEAK) I thought I'd post it here and see if anybody can help.
Thanks