Solved

Adapt jQuery Selectbox plugin to add extra class to select list

Posted on 2013-01-08
4
837 Views
Last Modified: 2013-01-08
Hi All,

I'm using a jQuery Selectbox plugin from the following location: http://www.bulgaria-web-developers.com/projects/javascript/selectbox/

It works fine except that I would like to be able to add a class to either the <a> link  or <li> that has been chosen by the user so when the dropdown is opened again, I can have styled that <li> to look like the active selection.

So when the user clicks on a list option, either the <a> or <li> get an additional class of 'selected' or whatever which is then removed when you click on another option.

Any ideas?

Many thanks.
jquery.selectbox-0.2.zip
0
Comment
Question by:b24
  • 2
4 Comments
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 38755257
Like most "free" plugins, there does not appear to be any support.  I suggest you try to contact the author, because I doubt anyone is going to try and modify the library for you.

Cd&
0
 
LVL 25

Accepted Solution

by:
Kyle Hamilton earned 500 total points
ID: 38755282
You could try something like this. (the onOpen, and onClose you can remove if you want)


$("#selectlist").selectbox({
	onOpen: function (inst) {
		//console.log("open", inst);
	},
	onClose: function (inst) {
		//console.log("close", inst);
	},
	onChange: function (val, inst) {
		$(this).find("option").filter(":selected").addClass("selected");
	},
	effect: "slide"
});

Open in new window

0
 

Author Closing Comment

by:b24
ID: 38755545
Thanks kozaiwaniec !
0
 
LVL 25

Expert Comment

by:Kyle Hamilton
ID: 38755575
my pleasure :))
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

So you have coded your own WordPress plugin and now you want to allow users to upload images to a folder in the plugin folder rather than the default media location? Follow along and this article will show you how to do just that!
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
In this tutorial viewers will learn how to embed custom externally-hosted Google Fonts using the Google Font API in CSS Go to the Google Fonts website at google.com/fonts: Browse or search based on font properties or name to find a suitable font for…
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)

785 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