본문 바로가기

개발/Javascript15

Javascript Date compare // -1 : adate가 작음, 0: 같음, 1: adate가 큼function compareDate(adate, bdate) {  // 연도, 월, 일, 시, 분 순서대로 비교  if (adate.getFullYear() !== bdate.getFullYear()) {    return adate.getFullYear() bdate.getFullYear() ? -1 : 1;  }  if (adate.getMonth() !== bdate.getMonth()) {    return adate.getMonth() bdate.getMonth() ? -1 : 1;  }  if (adate.getDate() !== bdate.getDate()) {    return adate.getDate() bdate... 2022. 1. 25.
Javascript C# String.Format 메서드와 동일한 기능 // C# String.Format 메서드와 동일하게 동작시키기 위한 함수 String.format = function () { // The string containing the format items (e.g. "{0}") // will and always has to be the first argument. var theString = arguments[0]; // start with the second argument (i = 1) for (var i = 1; i 2022. 1. 18.
jQuery selector like 검색 jQuery 셀렉터 like 검색은 3종류( ^, *, $ )가 있다.// 첫 문자가 같은 문자열// SQL의 where class like 'search%'$("[class^='search']");$("div[class^='search']");// contains 와 같은 기능// SQL의 where class like '%search%'$("[class*='search']");$("div[class*='search']");// 끝 문자가 같은 문자열// SQL의 where class like '%search'$("[class$='search']");$("div[class$='search']"); 2022. 1. 17.
Javascript SetCookie GetCookie function getCookie(key) {  const arg = key + '=';  const cookieLength = document.cookie.length;  let i = 0;  while (i cookieLength) {    const j = i + arg.length;    if (document.cookie.substring(i, j) === arg) {      let endString = document.cookie.indexOf(';', j);      if (endString === -1) {        endString = document.cookie.length;      }      return decodeURIComponent(document.cookie.subs.. 2022. 1. 12.
반응형