Solved

jQuery: Slide Down Pretty Select on Hover

Posted on 2013-05-22
2
521 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Hi all! Recently there was EE question and the person wanted to have a multi-column textbox <div> selection, so as a first step to answer I provided a link but that was not complete with JavaScript selection, but had a good style sheet. So as a ques…
Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
The viewer will learn how to dynamically set the form action using jQuery.
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)
Suggested Courses

621 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