Sometimes you might need to design different UI for mobile devices according to operating system and its version. So to know on which OS and OS version the device is operating, you can use PhoneGap by following the steps bellow.
2.Add the event listener to load the function when device gets ready.
var deviceOS = device.platform ; //fetch the device operating system
var deviceOSVersion = device.version ; //fetch the device OS version
alert("Device OS: " + deviceOS);
alert("Device OS Version: " + deviceOSVersion);