Solved

jQuery: Slide Down Pretty Select on Hover

Posted on 2013-05-22
2
501 Views
Last Modified: 2013-06-03
Now you have to click on "Choose One" to see the drop down options.  I want the options to slide down so you can see them when you hover over "Choose One".
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Example</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){

 pretty_selects();

});
	
function pretty_selects() {
        $('.styled-select').each(function () {
            $(this).wrap('<div class="pretty-select" />')
            $('<div class="select-text" />').prependTo($(this).parent('.pretty-select'));
            $(this).parent().children('.select-text').text($(this).attr('name').replace(/_/gi, ' '));
        }).change(function () {
            $(this).parent().children('.select-text').text($(this).children('option:selected').text());
        });
}

</script>
<style type="text/css">

body {
background: #eeeeff;
}

.pretty-select{
	height: 35px;
	position: relative;
	width:200px;
}

.pretty-select .select-text{
	height: 35px; 
	line-height: 35px;
	text-indent: 10px;
	color: #fff;
	background: #aaa;
	border: 1px solid #222;
}

.pretty-select select{	
	width: 100%;
	position: absolute;
	top: 0;
	right: 0; bottom: 0;
	opacity: 0;
	filter:alpha(opacity=0);
}
.pretty-select select option{
	padding: 5px 0;
	text-indent: 10px;
	border-bottom: 1px dotted #ccc;
}
.pretty-select select option:hover{
	background-color: #d6d6d6;
	cursor: pointer;
}

</style>
</head>
<body>

<select name="Choose_One" class="styled-select"> 
<option value="a">Option 1</option> 
<option value="b">Option 2</option> 
<option value="c">Option 3</option> 
<option value="d">Option 4</option> 
<option value="e">Option 5</option> 
</select> 

</body>
</html>

Open in new window

0
Comment
Question by:hankknight
2 Comments
 
LVL 15

Expert Comment

by:Jagadishwor Dulal
ID: 39189594
0
 
LVL 6

Accepted Solution

by:
mickey159 earned 500 total points
ID: 39189800
It is impossible to open a <select> by using hover. However, it is possible to use a drop down menu. Therefore, if the value is not going to be submitted in a form, try replace it with a drop down menu.
0

Featured Post

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have answered several questions lately that were solved utilizing the power of jQuery's AJAX functions, so I thought I would write an article demonstrating the ease of use. Why should I use jQuery as opposed to regular JavaScript? Now I know…
DOM Attributes and Properties treatment with jQuery 1.6 by Ivo Stoykov jQuery (http://jquery.com/) 1.6 introduces .prop() (http://api.jquery.com/prop/) and .removeProp() (http://api.jquery.com/removeProp/) methods which allow modifying or removi…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question