Trigger event in HTML <select> box when the same entry is selected again
HTML <select> 元素,选择相同条目时不触发 onchange 事件的解决方法:
下面例子中,jquery语法,其中select的id为lang:
$("select#lang").mouseup(function() {
var open = $(this).data("isopen");
if(open) { // 这里写下你的代码即可!
var code = hljs.highlight(window.getSelection().toString(), {language: langSelect[langSelect.selectedIndex].value}).value;
sel = window.getSelection();
sel.getRangeAt(0).deleteContents();
insertHtmlAtCursor("<pre class='code'>" + code + "</pre>");
}
$(this).data("isopen", !open);
});