본문 바로가기
반응형

Web Programing!/Script45

[Javascript] 배열 최대값, 최소값 구하기 1. 최대값 var arr = [3, 0, 7, 12, 0, 5, 22]; var maxValue = Math.max.apply(null, arr); 2. 최소값 var arr = [3, 0, 7, 12, 0, 5, 22]; var minValue = Math.min.apply(null, arr.filter(Boolean)); Boolean(3) // true Boolean(0) // false Boolean(7) // true //... arr.filter는 제공된 함수로 구현 된 테스트를 통과하는 모든 요소를 ​​사용하여 새 배열을 만듭니다. 결과적으로 0을 제외한 모든 요소를 ​​가진 새로운 필터링 된 배열을 갖게됩니다. #최소값구하기, #최대값구하기, #javascript최대값구하기, #javas.. 2021. 11. 26.
[Thymeleaf] 타임리프 속성 1. th:each (반복문) - 순서대로 list = 사용할 변수명, i = 인덱스, ${} = 받을 리스트 객체 선택 2. th:with (변수사용) - th:with="변수1=xxx, 변수2=yyy" 식으로 여러 개의 변수 선언 가능 3. th:value (값 넣기) 4. th:text (텍스트 넣기) 5. th:attr (속성 추가) 허용 여부 예 아니오 6. th:classappend (클래스 추가) 7. th:action 8. th:href 9. th:if (조건문) 등록 삭제 #타임리프, #thymeleaf, #타임리프속성, #타임리프class추가, #타임리프if, #타임리프반복문 2021. 11. 25.
[Javascript] selectbox 제어 1. jQuery로 선택된 값 읽기 $("#selectBox option:selected").val(); $("select[name=name]").val(); 2. jQuery로 선택된 내용 읽기 $("#selectBox option:selected").text(); 3. 선택된 위치 var index = $("#test option").index($("#test option:selected")); 4. Add options to the end of a select $("#selectBox").append("Apples"); $("#selectBox").append("After Apples"); 5. Add options to the start of a select $("#selectBox").prepe.. 2021. 11. 23.
[javascript] 쿠키(Cookie) 사용 2 - Plug-in 1. 플러그인 사이트에서 다운. https://plugins.jquery.com/cookie/ 2. 플러그인 추가. - jquery 플러그인이기 때문에 jquery도 같이 추가 3. 쿠키 생성. // 세션 쿠키 생성 - 브라우저를 닫으면 없으집니다. $.cookie('name', 'value'); // 7일 뒤에 만료되는 쿠키 생성 $.cookie('name', 'value', { expires: 7 }); // 전체 사이트에 대해 7일 뒤에 만료되는 쿠키 생성 $.cookie('name', 'value', { expires: 7, path: '/' }); // 세션 쿠키 생성 - 브라우저를 닫으면 없으집니다. $.cookie('name', 'value'); // 7일 뒤에 만료되는 쿠키 생성 $.coo.. 2021. 11. 21.
반응형