Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Copy attributes from original OPTION elements #228

Open
vertigoelectric opened this issue Jun 8, 2018 · 1 comment
Open

Copy attributes from original OPTION elements #228

vertigoelectric opened this issue Jun 8, 2018 · 1 comment

Comments

@vertigoelectric
Copy link

My original OPTION elements have attributes that I need to interact with through the selectric dropdowns. In this particular case, I need to the "title" attribute in order to get some text to pop up when hovering over an option.

How can I get selectric to copy the attribute from the original OPTION elements to the selectric LI elements?

@vertigoelectric
Copy link
Author

For now, this actually seems to do the job:

		$('select').each(function() {
			$('option').each(function() {
				var option = $(this);
				var title = option.attr("title");
				if(title)
				{
					var name = option.text();
				
					option.closest(".selectric-wrapper").find(".selectric-items").find("ul > li").each(function() {
						if ($(this).text() == name)
						{
							$(this).attr("title",title);
						}
					});
					
					//console.log(name + ":  " + title);					
				}				
			});
		});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant