Solved

jQuery: Slide Down Pretty Select on Hover

Posted on 2013-05-22
2
486 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Css issue on scroll 1 38
Jquery autocomplete 10 68
CSS Scroll Issue 3 81
How to load images into my server when they are requested from different computers 2 21
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
Introduction JSON is an acronym for JavaScript Object Notation.  It is a text-string data transport mechanism, capable of representing simple or complex data structures in a consistent and easy-to-read manner.  Similar in concept to XML, but more e…
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…

919 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now