Reputation: 790
I have a form with a select currently in use and an empty div (#price) below the form . I was wondering if anyone knew how (using jquery), to make it so that if I chose something in the select, to output it to the box. Or is the best solution to have the prices already loaded into the empty div, and just hide them using css?
Upvotes: 0
Views: 74
Reputation: 23132
$('#selectID').change(function() {
$('#divID').text($(this).find(':selected').text());
});
Or, if you want the value...
$('#selectID').change(function() {
$('#divID').text($(this).val());
});
Upvotes: 1
Reputation: 174957
You could do something like this:
$('#select').change(function() {
$('#price').text($(this).val());
});
Upvotes: 1
Reputation: 3533
What about this:
$("#select-id").change(function() {
$("#price").text($("#select-id").val());
});
Upvotes: 0