标签云

微信群

扫码加入我们

WeChat QR Code

I have a select box with a number of options. When a selection is made, I replace the displayed text using JQuery:$("#dropdownlist").change(function () {var selected = $(this).find(":selected");selected.text('foo');});I'd then like to restore the original value when the select is dropped down. How can I do this?I've tried using the 'click' event but this gets fired multiple times throughout the selection process, meaning that 'foo' always gets overwritten.Thanks in advance.


Does this drop down has an open event?

2019年04月20日16分39秒

What is the purpose of doing this? What are you trying to accomplish?

2019年04月20日16分39秒

gdoron As far as I'm aware, an open event isn't available.

2019年04月20日16分39秒

elclanrs My options display detailed information to help the user make their selection. In the interests of a clean UI, I don't wish to display this once the user has made their choice.

2019年04月19日16分39秒

Fantastic solutions - especially the first. Thank you.

2019年04月20日16分39秒

His problem is when to restore it, anyway, .data('oldtext') is better.

2019年04月19日16分39秒

Using the "mouse" events to change and restore depending if it is over or going off the select element may work. Am I right?

2019年04月20日16分39秒

Depends on the browser. read this

2019年04月19日16分39秒