このjQueryコードをスタンドアロンのJavaScriptとして実行することは可能ですか?これは私のプロジェクトで使用したい唯一のJavaScriptなので、この1kスクリプトのためだけにjqueryライブラリ全体をロードしたくないのです。
//chris coyier's little dropdown select-->
$(document).ready(function() {
//build dropdown
$("<select />").appendTo("nav.primary");
// Create default option "Go to..."
$("<option />", {
"selected": "selected",
"value" : "",
"text" : "Go to..."
}).appendTo("nav select");
// Populate dropdowns with the first menu items
$("div#brdmenu ul li a").each(function() {
var el = $(this);
$("<option />", {
"value" : el.attr("href"),
"text" : el.text()
}).appendTo("nav.primary select");
});
//make responsive dropdown menu actually work
$("nav.primary select").change(function() {
window.location = $(this).find("option:selected").val();
});
});
私は以前の答えを見つけようとしましたが、ほとんどの質問はjqueryに変換するためのものであり、その逆ではありません:)