이베리스
Iberis
이베리스
전체 방문자
오늘
어제
  • 전체보기 (72)
    • Course (64)
      • MS-SQL (10)
      • MY-SQL (12)
      • Oracle (2)
      • PostgreSQL (1)
      • ASP.NET with C# (5)
      • PHP (14)
      • Java (1)
      • javaScript (11)
      • A quick tip (1)
      • CodeIgniter (1)
      • CSS (3)
      • 운영체제 (2)
      • Git (1)
      • 리눅스 (0)
    • Utility (4)
    • 와우 (2)
      • 애드온 (2)

블로그 메뉴

  • 홈
  • 태그
  • 미디어로그
  • 위치로그
  • 방명록

공지사항

인기 글

태그

  • dbo
  • 공유폴더
  • comma
  • 테이블
  • 19c
  • 1326
  • 구조 복사
  • 삭제
  • 3DP
  • 수동삭제
  • 테이블 복사
  • power point
  • 이베리스
  • wowclassic
  • 접속안됨
  • Elv
  • 콤마
  • 렌카드
  • 와우클래식
  • 3자리
  • MSSQL
  • 쿼리
  • 보안 주체
  • Benik
  • share
  • 자동 줄 바꿈
  • width
  • table
  • 15517
  • error

최근 댓글

최근 글

티스토리

hELLO · Designed By 정상우.
이베리스

Iberis

Course/javaScript

jquery 간단한 정리

2013. 12. 24. 19:05

1. jQuery로 선택된 값 읽기

 

$("#selectBoxoption:selected").val();

$("select[name=name]").val();

 

2. jQuery로 선택된 내용 읽기

 

$("#selectBoxoption:selected").text();

 

3. 선택된 위치

 

var index =$("#test option").index($("#test option:selected"));

 

4. Addoptions to the end of a select

 

$("#selectBox").append("<optionvalue='1'>Apples</option>");

$("#selectBox").append("<optionvalue='2'>After Apples</option>");

 

5. Addoptions to the start of a select

 

$("#selectBox").prepend("<optionvalue='0'>Before Apples</option>");

 

6. Replaceall the options with new options

 

$("#selectBox").html("<optionvalue='1'>Some oranges</option><option value='2'>MoreOranges</option>");

 

7. Replaceitems at a certain index

 

$("#selectBoxoption:eq(1)").replaceWith("<option value='2'>Someapples</option>");

$("#selectBoxoption:eq(2)").replaceWith("<option value='3'>Somebananas</option>");

 

8. 지정된 index값으로 select 하기

 

$("#selectBoxoption:eq(2)").attr("selected", "selected");

 

9. text 값으로 select 하기

 

$("#selectBox").val("Someoranges").attr("selected", "selected");

 

10. value값으로 select 하기

 

$("#selectBox").val("2");

 

11. 지정된 인덱스값의 item 삭제

 

$("#selectBoxoption:eq(0)").remove();

 

12. 첫번째 item 삭제

 

$("#selectBoxoption:first").remove();

 

13. 마지막 item 삭제

 

$("#selectBoxoption:last").remove();

 

14. 선택된 옵션의 text 구하기

 

alert(!$("#selectBoxoption:selected").text());

 

15. 선택된 옵션의 value 구하기

 

alert(!$("#selectBoxoption:selected").val());

 

16. 선택된 옵션 index 구하기

 

alert(!$("#selectBoxoption").index($("#selectBox option:selected")));

 

17. SelecBox 아이템 갯수 구하기

 

alert(!$("#selectBoxoption").size());

 

18. 선택된 옵션 앞의 아이템 갯수

 

alert(!$("#selectBoxoption:selected").prevAl!l().size());

 

19. 선택된 옵션 후의 아이템 갯수

 

alert(!$("#selectBoxoption:selected").nextAll().size());

 

20. Insertan item in after a particular position

 

$("#selectBoxoption:eq(0)").after("<option value='4'>Somepears</option>");

 

21. Insertan item in before a particular position

 

$("#selectBoxoption:eq(3)").before("<option value='5'>Someapricots</option>");

 

22. Gettingvalues when item is selected

 

$("#selectBox").change(function(){

           alert(!$(this).val());

           alert(!$(this).children("option:selected").text());

});

저작자표시 비영리 변경금지 (새창열림)

'Course > javaScript' 카테고리의 다른 글

javascript checkbox checked 처리 ie, 크롬 다되는거  (0) 2015.06.10
chrome(크롬)에서 location.href 가 안될 때  (0) 2015.06.10
textarea 부모 객체 사이즈에 맞게 리사이즈 (jquery)  (0) 2014.10.08
Enter키 폼 전송 막기  (0) 2013.12.30
라디오버튼 체크값 알아오기  (0) 2013.12.05
    'Course/javaScript' 카테고리의 다른 글
    • chrome(크롬)에서 location.href 가 안될 때
    • textarea 부모 객체 사이즈에 맞게 리사이즈 (jquery)
    • Enter키 폼 전송 막기
    • 라디오버튼 체크값 알아오기
    이베리스
    이베리스
    Developer

    티스토리툴바