[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 888
  • Last Modified:

Adapt jQuery Selectbox plugin to add extra class to select list

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
b24
Asked:
b24
  • 2
1 Solution
 
COBOLdinosaurCommented:
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
 
Kyle HamiltonData ScientistCommented:
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
 
b24Author Commented:
Thanks kozaiwaniec !
0
 
Kyle HamiltonData ScientistCommented:
my pleasure :))
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now