我尝试使用下拉菜单在所有字段上设置默认值。例如:
Let consider Drop down there is of three options like theme1, theme2 and theme
3 and I have 5 input fields.
in the five input fields
have 适当的id
。
如果我选择theme1
它会将值初始化为适当的5
输入字段。(我不确定是否有办法将值分配给数组)
主题1包含
input1 => "hi";
input2 => "how";
input3 =>"are";
input4 =>"you";
如果我在下拉列表中选择主题 1,则添加我在数组中定义的值(如果可行)主题 2 包含
input1 => "glad";
input2 => "to";
input3 =>"meet";
input4 =>"you";
如果我选择theme2
它会将值初始化为适当的5
输入字段。(此值与主题1不同)
$('select').on('change', function() {
$("select option:selected").each(function () {
$('#price').val('$' + $(this).attr('value'));
});
});
现在我提到了价值。但是有没有一种方法可以调用函数而不是任何人都可以建议我使用数组的一个选项(主题1)的一组初始化值来执行此操作。这是我的小提琴