I want to add ellipsis in the dropdown list options if I click the ellipsis able to see the full option values
for example, dropdown list looking like this
<select id ="id">
<option>One - A long text need to be cut off with ellipsis</option>
<option>Two - A long text need to be cut off with ellipsis</option>
</select>
I am expecting the output like as follows
One - A long option.... Two - A long option....
when clicking the ellipses able to see the full option values like One - A long text need to be cut off with ellipsis
Please see the code which I done so far
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<style>
select {
width:200px;
}
</style>
<script>
$(document).ready(function() {
var maxLength = 20;
$('#example > option').text(function(i, text) {
if (text.length > maxLength) {
return text.substr(0, maxLength) + '...';
}
});
});
</script>
</head>
<body>
<select name="example" id="example">
<option value="">John Smith,1019 Your Company PO Box 7169 Poole BH15 9EL</option>
<option value="">91 Western Road,Brighton PO Box 7169 East Sussex England BN1 2NWL</option>
<option value="">John Smith,1019 Your Company PO Box 7169 Poole BH15 9EL</option>
</select>
</body>
</html>
Please help me to get the expected result as above