이 기사의 예에서는 jQuery 시간 플러그인 jquery.clock.js의 사용법을 설명합니다. 참고하실 수 있도록 모든 사람과 공유하세요. 자세한 내용은 다음과 같습니다.
예 1:
기본 시계, 옵션 없음
<html> <head> <title>jclock</title> <mce:script type="text/javascript" src="jquery-1.2.1.min.js" mce_src="jquery-1.2.1.min.js"></mce:script> <mce:script type="text/javascript" src="jquery.jclock.js" mce_src="jquery.jclock.js"></mce:script> <mce:script type="text/javascript"><!-- $(function($) { $('.jclock').jclock(); }); // --></mce:script> </head> <body> <div class="jclock"></div> </body> </html>
예 2:
시계, 비UTC, 옵션 포함
<html> <head> <title>jclock</title> <mce:script type="text/javascript" src="jquery-1.2.1.min.js" mce_src="jquery-1.2.1.min.js"></mce:script> <mce:script type="text/javascript" src="jquery.jclock.js" mce_src="jquery.jclock.js"></mce:script> <mce:script type="text/javascript"><!-- $(function($) { var options = { timeNotation: '12h', am_pm: true, fontFamily: 'Verdana, Times New Roman', fontSize: '20px', foreground: 'yellow', background: 'red' } $('.jclock').jclock(options); }); // --></mce:script> </head> <body> <div class="jclock"></div> </body>
예 3:
시계, UTC
<html> <head> <title>jclock <mce:script type="text/javascript" src="jquery-1.2.1.min.js" mce_src="jquery-1.2.1.min.js"></mce:script> <mce:script type="text/javascript" src="jquery.jclock.js" mce_src="jquery.jclock.js"></mce:script> <mce:script type="text/javascript"><!-- $(function($) { var options = { utc: true } $('.jclock').jclock(options); }); // --></mce:script> </title></head> <body> <div class="jclock"></div> </body> </html>
예 4:
다른 시간대 오프셋을 사용하는 여러 시계
<html> <head> <title>jclock</title> <mce:script type="text/javascript" src="jquery-1.2.1.min.js" mce_src="jquery-1.2.1.min.js"></mce:script> <mce:script type="text/javascript" src="jquery.jclock.js" mce_src="jquery.jclock.js"></mce:script> <mce:script type="text/javascript"><!-- $(function($) { var optionsEST = { utc: true, utc_offset: -5 } $('#jclock1').jclock(optionsEST); var optionsCST = { utc: true, utc_offset: -6 } $('#jclock2').jclock(optionsCST); var optionsIndia = { utc: true, utc_offset: 5.5 } $('#jclock3').jclock(optionsIndia); }); // --></mce:script> </head> <body> <p>EST: <span id="jclock1"></span></p> <p>CST: <span id="jclock2"></span></p> <p>India: <span id="jclock3"></span></p> </body> </html>
예 5:
스타일 시계(첫 번째 시계는 jquery.corner.js를 사용함)
<html> <head> <title>jclock</title> <mce:style type="text/css"><!-- body { font: Verdana,Arial,sans-serif; /* An explicit background color is required for Safari. */ /* Otherwise your corner chunks will come out black! */ background: #f8f0e0; } div.corner, div.nocorner { width: 10em; padding: 20px; margin: 1em; background: #f00; color: #000; text-align: center; font: verdana, arial, sans-serif; } --></mce:style><style type="text/css" mce_bogus="1"> body { font: Verdana,Arial,sans-serif; /* An explicit background color is required for Safari. */ /* Otherwise your corner chunks will come out black! */ background: #f8f0e0; } div.corner, div.nocorner { width: 10em; padding: 20px; margin: 1em; background: #f00; color: #000; text-align: center; font: verdana, arial, sans-serif; } </style> <mce:script type="text/javascript" src="jquery-1.2.1.min.js" mce_src="jquery-1.2.1.min.js"></mce:script> <mce:script type="text/javascript" src="jquery.jclock.js" mce_src="jquery.jclock.js"></mce:script> <mce:script type="text/javascript" src="jquery.corner.js" mce_src="jquery.corner.js"></mce:script> <mce:script type="text/javascript"><!-- $(function($) { var options = { timeNotation: '12h', am_pm: true, fontFamily: 'Verdana, Times New Roman', fontSize: '20px', foreground: 'yellow', background: 'red' } $('.jclock').jclock(options); $('.corner').corner("30px"); }); // --></mce:script> </head> <body> <p><div class="corner"><div class="jclock"></div></div></p> <p><div class="nocorner"><div class="jclock"></div></div></p> </body> </html>
이 기사가 jQuery 프로그래밍에 종사하는 모든 사람에게 도움이 되기를 바랍니다.