Using jquery to display value
I have a form with a select currently in us开发者_运维知识库e 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?
$('#selectID').change(function() {
$('#divID').text($(this).find(':selected').text());
});
Or, if you want the value...
$('#selectID').change(function() {
$('#divID').text($(this).val());
});
You could do something like this:
$('#select').change(function() {
$('#price').text($(this).val());
});
Example
What about this:
$("#select-id").change(function() {
$("#price").text($("#select-id").val());
});
精彩评论