1
2
3
4
5
6
7
8
9
10
11
$(document).ready(function () {
    $('a').on('click'function () {
        var $this = $(this); //클릭된 a요소
        var liClass = $this .parent().attr('class'); //a의 부모의 속성중 class 속성의 값을 가져옴
        console.log(liClass);
    }) ;
}) ;
 
//클래스 안에 숫자 가져오는 법
var itemVal = parseInt($(this).attr('class').replace(/[^0-9]/g,''));
 
cs


  • 지역별 시간계산 구조
  1. DB에 저장된 시간(한국시간)을 GMT 시간 A로 변환
  2. 사용자의 기기브라우저 시간과 GMT 시간차이 계산해서 B를 가져옴 (ex: America/New_York : -04:00)
  3. A + B

ex) 
[DB시간(한국)]              -> GMT+0:00 변환              -> 현지시간(ex:America/New_York)과 GMT+0:00차이 시간(-4:00)을 더함]
[2015-03-12 08:08:42] -> [2015-03-11 23:08:42] -> [2015-03-11 19:08:42]



결과 (ex: 미국 동부 표준시)


1
2
3
4
5
6
7
8
9
10
function ChkRegNum(val) { 
    if (event.keyCode < 48 || event.keyCode > 57) { 
        if (event.keyCode != 46) { 
            alert('숫자만 입력!'); return false
        } else { 
            return true
        } 
    } 
    return true
}
cs


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
//aspx.cs
using System.Web.Script.Serialization;
namespace Test_Kmh.Dev_ASP.NET
{
  public partial class test01 : System.Web.UI.Page
  {
    private string type 
    { 
        get 
        { 
            return string.IsNullOrEmpty(Request.Form["Type"]) ? string.Empty : Request.Form["Type"]; 
        } 
    }
    // 리턴클래스 설정
    ReturnClass rtnClass = new ReturnClass();
    protected void Page_Load(Object sender, EventArgs e)
    {
      if(Type == "1")
      {
        rtnClass.RtnStr = "ABC";
        return;
      }
    }
    /// 
    /// Json형식으로 리턴
    /// 
    protected override void OnPreRender ( EventArgs e )
    {
      base .OnPreRender ( e);
      string json = new JavaScriptSerializer () .Serialize ( retInfo);
      Response .Write ( json);
    }
    /// 
    /// 리턴 클래스
    /// 
    public class ReturnClass
    {
      public string RtnStr = "";
    }
  }
}
cs


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
//javascript
<script type"text/javascript" src="jq-1.10.2.js"></script>
<script type"text/javascript">
  function ajaxCall(){
    $.ajax({
      type: 'POST',
      cache: false,
      async: false,
      url: 'test01.aspx',
      dataType: 'html',
      data : { type: '1' },
      success: function(result){
        var data = jQuery.parseJSON(result);
        //리턴받아서 출력
        alert(data.RtnStr);
      }
    });
  }
</script>
cs


a태그에 history.back()을 설정할때 onclick에 설정하는 경우 작동하지 않는 경우가 발생할 수 있음. 그래서 href에 history.back()을 설정하면 잘 작동 됨.

1
<a href="javascript:window.history.back();">BtnBack</a>
cs


1
2
3
4
5
6
7
8
9
10
11
12
13
///// Script /////
<script type="text/javascript" src="jquery.min.js" charset="euc-kr">
<script type="text/javascript">
     function LoadImg(value) {
          if(value.files && value.files[0]) {
               var reader = new FileReader();
               reader.onload = function (e) {
                    $('#LoadImg').attr('src', e.target.result);
               }
               reader.readAsDataURL(value.files[0]);
          }
     }
</script>
cs


1
2
3
4
5
///// html /////
// 파일 업로드하는 곳
<pre class="brush:html"><input type="file" id="imgAttach" name="imgAttach" onchange="LoadImg(this);">
// 미리보기 이미지 출력되는 곳
<img id="LoadImg">
cs


1
2
$('select[name="selectboxname"]').val() //Value
$("#selectboxid option:selected").text()   //Text
cs


1
$(':radio[name="radiobuttonname"]:checked').val()
cs


1
2
3
$ ( ':checkbox[name="chkboxname"]:checked' ).map ( function () {
     return this . value;
}). get(). join ('|')   //'|'은 구분자
cs


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
//trident
//ie7 : null, ie8 : 4.0, ie9 : 5.0, ie10 : 6.0, ie11 : 7.0
var trident = navigator.userAgent.match(/Trident\/(\d.\d)/i); 
 
//msie
var rv = -1;
var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
if(re.exec(navigator.userAgent) != null) rv = parseFloat(RegExp.$1);
 
if( rv <= 7 ) //msie check (ie7~ie10 : 7~10, ie11 : -1)
{
     if(trident != null// trident check (ie8~11 : 4.0~7.0, ie7 : null)
     {
          if(trident[1== "7.0" && rv == 7// trident = ie11 && msie = ie7
          {
               alert("IE11 호환성체크");
          }
               else if(trident[1!= "7.0"// trident = ie8,9,10 && msie = ie7
          {
               alert("IE8,9,10 호환성체크");
          }
     }
     else // ie7 || other browser
     {
          if(navigator.appName == 'Microsoft Internet Explorer'//ie7
          {
               alert("IE 7이하");
          }
     }
}
 
cs


+ Recent posts