검색결과 리스트
JS에 해당되는 글 43건
- 2014.05.17 그림그리기
- 2014.05.17 context
- 2014.05.17 one method
- 2014.05.17 mouse event 2
- 2014.05.17 mouse event
글
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 42 43 44 45 46 47 48 49 50 | <!DOCTYPE html> <html> <head> <title>hello</title> <script src='./js/jquery-1.11.1.js'></script> <script src='./js/ch15.js'> </script> <style> * {margin: 0px; padding: 0px} div{ margin: 5px; padding: 3px; border: 3px solid black; border-radius: 10px; } </style> <script> $(document).ready(function() { var canvas = document.getElementById('canvas'); var context = canvas.getContext('2d'); $(canvas).on({ mousedown: function(event){ var position = $(this).offset(); var x = event.pageX - position.left; var y = event.pageY - position.top; console.log(position.left,position.top); context.beginPath(); context.moveTo(x,y); }, mouseup: function(event){ var position = $(this).offset(); var x = event.pageX - position.left; var y = event.pageY - position.top; console.log(position.left,position.top); context.lineTo(x,y); context.stroke(); } }); }); </script> </head> <body> <br/> <canvas id='canvas' width='700' height='400' style='border: 3px solid black'> </canvas> </body> </html> |
글
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 | <!DOCTYPE html> <html> <head> <title>hello</title> <script src='./js/jquery-1.11.1.js'></script> <script src='./js/ch15.js'> </script> <style> * {margin: 0px; padding: 0px} div{ margin: 5px; padding: 3px; border: 3px solid black; border-radius: 10px; } </style> <script> $(document).ready(function() { $('div').click(function(){ var header = $('h1',this).text(); var paragraph = $('p',this).text(); alert(header + '\n' + paragraph); }); }); </script> </head> <body> <div> <h1>Header 1</h1> <p>Paragraph</p> </div> <div> <h1>Header 2</h1> <p>Paragraph</p> </div> <div> <h1>Header 3</h1> <p>Paragraph</p> </div> </body> </html> |
글
one method
JS
2014. 5. 17. 18:01
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 | <!DOCTYPE html> <html> <head> <title>hello</title> <script src='./js/jquery-1.11.1.js'></script> <script src='./js/ch15.js'> </script> <style> .reverse{ background: black; color: white; } </style> <script> $(document).ready(function() { $('h1').one({ mousedown: function(){ $(this).html('click'); alert("event occur");} }); }); </script> </head> <body> <h1>Header - 0</h1> <h1>Header - 1</h1> <h1>Header - 2</h1> </body> </html> |
글
mouse event 2
JS
2014. 5. 17. 17:36
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 | <!DOCTYPE html> <html> <head> <title>hello</title> <script src='./js/jquery-1.11.1.js'></script> <script src='./js/ch15.js'> </script> <style> .reverse{ background: black; color: white; } </style> <script> $(document).ready(function() { $('h1').click(function(){ $(this).html("CLICK"); alert("event occur"); $(this).off(); }); }); </script> </head> <body> <h1>Header - 0</h1> <h1>Header - 1</h1> <h1>Header - 2</h1> </body> </html> |
글
mouse event
JS
2014. 5. 17. 17:08
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 | <!DOCTYPE html> <html> <head> <title>hello</title> <script src='./js/jquery-1.11.1.js'></script> <script src='./js/ch15.js'> </script> <style> .reverse{ background: black; color: white; } </style> <script> $(document).ready(function() { $('h1').on('click', function(){ $(this).html(function(index, html){ return html + '+'; }); }); $('h1').on({ mouseenter: function(){ $(this).addClass('reverse'); }, mouseleave: function(){ $(this).removeClass('reverse'); } }); }); </script> </head> <body> <h1>Header - 0</h1> <h1>Header - 1</h1> <h1>Header - 2</h1> </body> </html> |