<select id="select" data-role="none">
<option gid="1" value="1" selected>Take Photo</option>
<option gid="0" value="0">Choose exist image</option>
</select>
注:此法使用phonegap, ios
用jquery为select分别绑定change和blur两个函数,change用来监听选取的是哪个option,blur用来最后获取select的值,并实现根据点击不同的option调用不同的函数功能。
//take photo or choose an exist picture
jQuery(document).ready(function() {
jQuery("#select").change(function() {
select_value = jQuery(this).val();
if (select_value == "1") {
pictureSource = navigator.camera.PictureSourceType.CAMERA;
} else {
pictureSource = navigator.camera.PictureSourceType.PHOTOLIBRARY;
}
});
jQuery("#select").blur(function(){
getPhoto(pictureSource);//getPhoto根据不同的pictureSourc值,实现不同的功能
});
});