jQuery로 선택된 값 읽기
$("#select_box option:selected").val();
$("select[name=name]").val();
jQuery로 선택된 내용 읽기
$("#select_box option:selected").text();
선택된 위치
var index = $("#test option").index($("#test option:selected"));
-------------------------------------------------------------------
$("#myselect").append("<option value='1'>Apples</option>");
$("#myselect").append("<option value='2'>After Apples</option>");
// Add options to the start of a select
$("#myselect").prepend("<option value='0'>Before Apples</option>");
// Replace all the options with new options
$("#myselect").html("<option value='1'>Some oranges</option><option value='2'>More Oranges</option><option value='3'>Even more oranges</option>");
// Replace items at a certain index
$("#myselect option:eq(1)").replaceWith("<option value='2'>Some apples</option>");
$("#myselect option:eq(2)").replaceWith("<option value='3'>Some bananas</option>");
// Set the element at index 2 to be selected
$("#myselect option:eq(2)").attr("selected", "selected");
// Set the selected element by text
$("#myselect").val("Some oranges").attr("selected", "selected");
// Set the selected element by value
$("#myselect").val("2");
// Remove an item at a particular index
$("#myselect option:eq(0)").remove();
// Remove first item
$("#myselect option:first").remove();
// Remove last item
$("#myselect option:last").remove();
// Get the text of the selected item
alert($("#myselect option:selected").text());
// Get the value of the selected item
alert($("#myselect option:selected").val());
// Get the index of the selected item
alert($("#myselect option").index($("#myselect option:selected")));
// Alternative way to get the selected item
alert($("#myselect option:selected").prevAll().size());
// Insert an item in after a particular position
$("#myselect option:eq(0)").after("<option value='4'>Some pears</option>");
// Insert an item in before a particular position
$("#myselect option:eq(3)").before("<option value='5'>Some apricots</option>");
// Getting values when item is selected
$("#myselect").change(function() {
alert($(this).val());
alert($(this).children("option:selected").text());
});
댓글 1개
13년 전
좋네요
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 430 | 19년 전 | 4133 | ||
| 429 | 19년 전 | 3325 | ||
| 428 | 19년 전 | 4146 | ||
| 427 | 19년 전 | 3493 | ||
| 426 | 19년 전 | 3122 | ||
| 425 | 19년 전 | 3431 | ||
| 424 | 19년 전 | 2454 | ||
| 423 | 19년 전 | 2882 | ||
| 422 | 19년 전 | 2374 | ||
| 421 | 19년 전 | 3729 | ||
| 420 | 19년 전 | 4758 | ||
| 419 | 19년 전 | 3834 | ||
| 418 |
|
19년 전 | 1769 | |
| 417 | 19년 전 | 2770 | ||
| 416 | 19년 전 | 2413 | ||
| 415 | 19년 전 | 2616 | ||
| 414 | 19년 전 | 4433 | ||
| 413 |
|
19년 전 | 2626 | |
| 412 | 19년 전 | 3070 | ||
| 411 |
|
19년 전 | 3006 | |
| 410 |
|
19년 전 | 3714 | |
| 409 |
|
19년 전 | 3656 | |
| 408 |
|
19년 전 | 1877 | |
| 407 | 19년 전 | 2247 | ||
| 406 | 19년 전 | 2813 | ||
| 405 | 19년 전 | 2478 | ||
| 404 | 19년 전 | 4328 | ||
| 403 | 19년 전 | 3318 | ||
| 402 |
NeoGenesis
|
19년 전 | 4114 | |
| 401 | 19년 전 | 2627 | ||
| 400 |
|
19년 전 | 2529 | |
| 399 | 19년 전 | 2982 | ||
| 398 | 19년 전 | 2516 | ||
| 397 | 19년 전 | 2811 | ||
| 396 | 19년 전 | 2514 | ||
| 395 | 19년 전 | 3221 | ||
| 394 | 19년 전 | 1761 | ||
| 393 | 19년 전 | 3020 | ||
| 392 | 19년 전 | 2291 | ||
| 391 | 19년 전 | 2195 | ||
| 390 | 19년 전 | 2305 | ||
| 389 | 19년 전 | 2667 | ||
| 388 | 19년 전 | 2211 | ||
| 387 | 19년 전 | 4499 | ||
| 386 |
|
19년 전 | 2706 | |
| 385 |
|
19년 전 | 2518 | |
| 384 | 19년 전 | 3053 | ||
| 383 | 19년 전 | 3081 | ||
| 382 | 19년 전 | 3127 | ||
| 381 |
|
19년 전 | 2654 | |
| 380 |
|
19년 전 | 3037 | |
| 379 | 19년 전 | 2563 | ||
| 378 | 19년 전 | 2234 | ||
| 377 | 19년 전 | 2796 | ||
| 376 | 19년 전 | 2483 | ||
| 375 |
|
19년 전 | 2581 | |
| 374 | 19년 전 | 3838 | ||
| 373 | 19년 전 | 3291 | ||
| 372 | 19년 전 | 5014 | ||
| 371 |
세은아빠2
|
19년 전 | 2437 | |
| 370 | 19년 전 | 4517 | ||
| 369 | 19년 전 | 3123 | ||
| 368 | 19년 전 | 2920 | ||
| 367 | 19년 전 | 3748 | ||
| 366 | 19년 전 | 2674 | ||
| 365 | 19년 전 | 3761 | ||
| 364 | 19년 전 | 4038 | ||
| 363 | 19년 전 | 3473 | ||
| 362 | 20년 전 | 3506 | ||
| 361 | 20년 전 | 4130 | ||
| 360 |
hwatta
|
20년 전 | 2386 | |
| 359 | 20년 전 | 5130 | ||
| 358 | 20년 전 | 3676 | ||
| 357 | 20년 전 | 2622 | ||
| 356 |
sdesign1s
|
20년 전 | 2301 | |
| 355 | 20년 전 | 2778 | ||
| 354 | 20년 전 | 3043 | ||
| 353 | 20년 전 | 2813 | ||
| 352 |
|
20년 전 | 5794 | |
| 351 |
|
20년 전 | 2730 | |
| 350 |
|
20년 전 | 4317 | |
| 349 |
hwatta
|
20년 전 | 2215 | |
| 348 | 20년 전 | 7325 | ||
| 347 | 20년 전 | 2431 | ||
| 346 | 20년 전 | 3529 | ||
| 345 | 20년 전 | 4332 | ||
| 344 | 20년 전 | 2675 | ||
| 343 | 20년 전 | 3940 | ||
| 342 | 20년 전 | 3087 | ||
| 341 | 20년 전 | 4119 | ||
| 340 |
|
20년 전 | 5177 | |
| 339 |
|
20년 전 | 4256 | |
| 338 | 20년 전 | 5899 | ||
| 337 | 20년 전 | 2064 | ||
| 336 |
|
20년 전 | 3357 | |
| 335 |
|
20년 전 | 3571 | |
| 334 |
|
20년 전 | 2966 | |
| 333 |
hwatta
|
20년 전 | 2470 | |
| 332 | 20년 전 | 4674 | ||
| 331 | 20년 전 | 2297 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기