Reputation: 178215
What am I missing here?
As part of an answer to How can i change options in dropdowns if it is generated dynamically?
I have an issue inside an onchange. I want to set all the siblings values to the value of the changed select
$("select").on("change",function() {
var idx=$(this).val();
console.log($(this).attr("id"),$(this).val())
$(this).siblings("select").each(function() {
$(this).val(idx);
});
});
Here is the generated code in a JSFIDDLE
I have seen
How do i get the value of all other dropdowns when one of them is changed
but I prefer to find the reason for my error
Upvotes: 1
Views: 2043
Reputation: 144699
You are using the val
method as a property.
var idx=$(this).val;
// ----^
You can also use the val
method instead of each
:
$("select").on("change", function() {
$(this).siblings("select").val(this.value);
});
Upvotes: 2