简单的新浪股票API调用
以后有时间,还记得的话,再做成JQuery 插件吧
-----
用到的东西:
1. sina stock API
2. JQuery [$.getScript()]
3. JS [Date.prototype.format]
-----
效果图:

-----
代码:
1 <!DOCTYPE html> 2 <head> 3 <title>CGM003</title> 4 <script src="js/libs/jquery-1.11.0.js"></script> 5 <style> 6 body{ 7 font-size:13px; 8 } 9 td{ 10 padding:1px 2px; 11 border-bottom:1px solid gray; 12 text-align:right; 13 vertical-align:bottom; 14 white-space:nowrap; 15 } 16 .red{ 17 color:red; 18 } 19 .green{ 20 color:green; 21 } 22 #infoTbl{ 23 font-size:15px; 24 } 25 </style> 26 </head> 27 <body> 28 <section> 29 <header> 30 间隔:<input type="number" id="refreshTime" min="100" max="5000" value="1000" />毫秒 31 <span id="refresh" style="cursor:pointer; text-decoration:underline; color:blue;"></span> 32 <span id="lastTime"></span> 33 (字体: <span style="cursor:pointer; text-decoration:underline; color:blue;" onclick="$('#infoTbl').css('font-size','15px');">小</span> <span style="cursor:pointer; text-decoration:underline; color:blue;" onclick="$('#infoTbl').css('font-size','20px');">中</span> <span style="cursor:pointer; text-decoration:underline; color:blue;" onclick="$('#infoTbl').css('font-size','25px');">大</span> <span style="cursor:pointer; text-decoration:underline; color:blue;" onclick="$('#infoTbl').css('font-size','55px');">超</span>) 34 <br /> 35 <select id="market"> 36 <option value="sh" selected >上海</option> 37 <option value="sz" >深圳</option> 38 </select> 39 代码: 40 <input type="text" size="7" id="code" value='' /> 41 <span style="cursor:pointer; text-decoration:underline; color:blue;" onclick="addStock();">添加</span> 42 </header> 43 <article> 44 <table id="infoTbl"> 45 </table> 46 </article> 47 </section> 48 49 <script> 50 // prototype of Date to add [format] meathod 51 Date.prototype.format =

本文介绍了如何简单调用新浪股票API,并提及未来可能将其封装为JQuery插件。内容涉及Sina stock API的使用,结合JQuery的$.getScript()方法以及JS的Date.prototype.format功能。还提供了代码示例及CSDN的下载链接。
5790

被折叠的 条评论
为什么被折叠?



