jquery 타이머

JAVASCRIPT 2014. 12. 25. 03:57 Posted by Dayis

var myTimer = setInterval(function() {

alert('Timer Start');    //함수실행

clearInterval(myTimer );    //타이머 중지

}, 3000);    //타이머 반복시간

'JAVASCRIPT' 카테고리의 다른 글

유튜브(Youtube) 동영상 로드, 종료 이벤트 API  (0) 2015.01.13
jquery 이미지 슬라이드  (0) 2014.12.25
[jQuery] window와 document 비교  (0) 2013.07.09
날씨 API  (0) 2013.07.03
jQuery ajaxForm plugin (form submit)  (0) 2013.06.17

[jQuery] window와 document 비교

JAVASCRIPT 2013. 7. 9. 15:35 Posted by Dayis

1. 전체 문서 크기 : 창크기에 상관없이 일정한 값을 가짐 

- 스크롤에 의해 보이지 않은 영역까지 포함

$(document).height();

$(document).width();


2. 메뉴바, 툴바, 스크롤바를 제외한 크기 : 창크기에 따라 값이 변경 

- 스크롤에 의해 보이지 않는 영역은 미포함

$(window).height();

$(window).width();

'JAVASCRIPT' 카테고리의 다른 글

jquery 이미지 슬라이드  (0) 2014.12.25
jquery 타이머  (0) 2014.12.25
날씨 API  (0) 2013.07.03
jQuery ajaxForm plugin (form submit)  (0) 2013.06.17
jQuery 모바일 터치슬라이드  (0) 2013.05.29

날씨 API

JAVASCRIPT 2013. 7. 3. 13:42 Posted by Dayis

//**********************************************************************************

//날씨 아이콘 추가 시작

// API : http://api.openweathermap.org/data/2.5/weather?q=seoul,kr

// Icon : http://bugs.openweathermap.org/projects/api/wiki/Weather_Condition_Codes

//**********************************************************************************

var WeatherMain="";

var WeatherIcon="";

var WeatherTemp="";

function RequestWeather() {

var param = {"q":"seoul"};

// cross-domain 접근을 위해 callback 추가

var json;

$.ajax({

url : "http://api.openweathermap.org/data/2.5/weather",

data : "q=seoul&callback=fnWeather",

dataType : "jsonp",

jsonp : "callback"

});

}


function fnWeather(res)

{

$.each(res, function(key,val){

if (key=="weather") {

$.each(val, function(key2,val2){

$.each(val2, function(key3,val3){

if (key3=="main") {

WeatherMain = val3;

} else if (key3=="icon"){

WeatherIcon = val3;

}

});

});

} else if (key=="main") {

$.each(val, function(key2,val2){

if (key2=="temp") {

WeatherTemp = val2;

}

});

}

});


//alert(WeatherMain+", "+WeatherIcon);

if (WeatherIcon != "") {

$("#spnWeather").html("<img src='http://openweathermap.org/img/w/"+WeatherIcon+".png' border='0' width='40'>");

}


if (WeatherTemp != "") {

WeatherTemp=(WeatherTemp-273.15).toFixed(1)    //절대온도를 섭씨온도로 변경

$("#spnTemp").html(WeatherTemp+"℃)");

}

}

//날씨 아이콘 추가 끝

'JAVASCRIPT' 카테고리의 다른 글

jquery 타이머  (0) 2014.12.25
[jQuery] window와 document 비교  (0) 2013.07.09
jQuery ajaxForm plugin (form submit)  (0) 2013.06.17
jQuery 모바일 터치슬라이드  (0) 2013.05.29
jQuery 특정영역(div)만 출력  (0) 2013.05.13

jQuery ajaxForm plugin (form submit)

JAVASCRIPT 2013. 6. 17. 17:18 Posted by Dayis

Plugin : http://jquery.malsup.com/form/#download

사용 예 : http://mytory.net/archives/223


$(function(){ $('#FormID').ajaxSubmit(); });


$(function(){ $('#FormID').ajaxSubmit({ success: function(msg){ alert(msg); } }); });


※ ajaxForm과 ajaxSubmit

ajaxForm : 실제 submit이 일어나기 전의 이벤트 리스너..??

ajaxSubmit : 실제 submit

'JAVASCRIPT' 카테고리의 다른 글

[jQuery] window와 document 비교  (0) 2013.07.09
날씨 API  (0) 2013.07.03
jQuery 모바일 터치슬라이드  (0) 2013.05.29
jQuery 특정영역(div)만 출력  (0) 2013.05.13
jQuery 엔터키 이벤트  (0) 2013.05.13

jQuery 모바일 터치슬라이드

JAVASCRIPT 2013. 5. 29. 15:50 Posted by Dayis

jQuery 모바일 터치슬라이드


https://github.com/lusever/TouchSlider


http://touchslider.com/

'JAVASCRIPT' 카테고리의 다른 글

날씨 API  (0) 2013.07.03
jQuery ajaxForm plugin (form submit)  (0) 2013.06.17
jQuery 특정영역(div)만 출력  (0) 2013.05.13
jQuery 엔터키 이벤트  (0) 2013.05.13
jQuery 숫자 포멧 변경 (콤마..)  (0) 2013.05.06

jQuery 특정영역(div)만 출력

JAVASCRIPT 2013. 5. 13. 18:29 Posted by Dayis


jquery.printArea.js

<html>

<head>

<script src="jquery-1.2.6.min.js" type="text/javascript"></script>

<script src="jquery.printArea.js" type="text/javascript"></script>

<script>

$(document).ready(function() {

   //////////

   // PrintArea

   ///////////

   $("#printButton").click(function(){

      $("#printable").printArea();

   });

});


</script>

</head>

<body>

<p><b>Example 5: PrintArea - Only the actual table will print, not the titles</b>

<p>An advertisement that you don't want printed out.

<p>Another advertisement that you don't want printed out.

<div id=printable>

<table width=40% cellpadding=3 cellspacing=0 border=1>

<tr><th>Name</th><th>Age</th><th>Height</th></tr>

<tr><td>John Q</td><td>23</td><td>6'1"</td></tr>

<tr><td>Jane Q</td><td>23</td><td>5'1"</td></tr>

<tr><td>Jimmy R</td><td>23</td><td>5'6"</td></tr>

<tr><td>Jamie W</td><td>23</td><td>5'9"</td></tr>

</table>

</div>

<p><input type=button id=printButton value="Print">

<p>All the annoying disclaimer text you don't want printed out.

</body>

</html>

'JAVASCRIPT' 카테고리의 다른 글

jQuery ajaxForm plugin (form submit)  (0) 2013.06.17
jQuery 모바일 터치슬라이드  (0) 2013.05.29
jQuery 엔터키 이벤트  (0) 2013.05.13
jQuery 숫자 포멧 변경 (콤마..)  (0) 2013.05.06
URL 정보 확인  (0) 2013.04.11

jQuery 엔터키 이벤트

JAVASCRIPT 2013. 5. 13. 07:02 Posted by Dayis

$('#pwd').live('keypress', function(e) {

if (e.which == 13) {/* 13 == enter key@ascii */

formCheck();

}

});

'JAVASCRIPT' 카테고리의 다른 글

jQuery 모바일 터치슬라이드  (0) 2013.05.29
jQuery 특정영역(div)만 출력  (0) 2013.05.13
jQuery 숫자 포멧 변경 (콤마..)  (0) 2013.05.06
URL 정보 확인  (0) 2013.04.11
숫자만 입력가능  (0) 2013.04.03

jQuery 숫자 포멧 변경 (콤마..)

JAVASCRIPT 2013. 5. 6. 12:07 Posted by Dayis

Easily format numbers for display use. Replace numbers inline in a document, or return a formatted number for other uses.


https://github.com/teamdf/jquery-number.git

'JAVASCRIPT' 카테고리의 다른 글

jQuery 특정영역(div)만 출력  (0) 2013.05.13
jQuery 엔터키 이벤트  (0) 2013.05.13
URL 정보 확인  (0) 2013.04.11
숫자만 입력가능  (0) 2013.04.03
[jQueryMobile] data-role="content" 높이 100%로 채우기  (0) 2012.11.13

URL 정보 확인

JAVASCRIPT 2013. 4. 11. 17:17 Posted by Dayis

<html>

<head>

<script type="text/javascript">

window.onload = function () {

 var hostname = window.location.hostname; 

 var href = window.location.href; 

 var host = window.location.host; 

 var port = window.location.port; 

 var pathname = window.location.pathname; 

 var search = window.location.search; 

 var protocoal = window.location.protocol;

 var _str = "hostname:" + hostname + "<br>";

 _str += "href:" + href + "<br>";

 _str += "host:" + host + "<br>";

 _str += "port:" + port + "<br>";

 _str += "pathname:" + pathname + "<br>";

 _str += "search:" + search + "<br>";

 _str += "protocoal:" + protocoal + "<br>";

 

 var hostname = window.location.hostname; 

 var _host;

 if (hostname.indexOf(".") > 0) {

  _host = hostname.split(".")[0];

 } else {

  _host = hostname;

 }

 document.getElementById("tmpDiv").innerHTML = "host:" + _host + "<hr>" + _str;

}

</script>

</head>

<body>

 <div id="tmpDiv" name="tmpDiv">

 </div>

</body>

</html>

숫자만 입력가능

JAVASCRIPT 2013. 4. 3. 00:18 Posted by Dayis

.....................................................................................................................................................................................................................................................

function onlyNumber(event) {
    var key = window.event ? event.keyCode : event.which;    

    if ((event.shiftKey == false) && ((key  > 47 && key  < 58) || (key  > 95 && key  < 106)
    || key  == 35 || key  == 36 || key  == 37 || key  == 39  // 방향키 좌우,home,end  
    || key  == 8  || key  == 46 ) // del, back space
    ) {
        return true;
    }else {
        return false;
    }    
};


호출하는 부분은 아래와 같다

<input type="text" name="test" value="test" style="ime-mode:disabled;" onkeydown="return onlyNumber(event)">


테스트해볼수 있는 곳


http://jsfiddle.net/cJSkd/4/