0

I am facing a scenario where select control is populating with values using php and I have coded against onChange when any value is changed then the changed value populate in the textbox.

BUT When select control has only one value then onchange does not work because there is only one value. How can I catch that value and populate in the textbox when the select control has only one value..

4

1 回答 1

0

you can get value of the only select element on jquery document.ready event by calling val() function on select object.

Live Demo

$(document).ready(function() {
    var selectedVal = $('#yourSelectId').val();
});
于 2013-01-05T14:11:40.970 回答