fmpq.com
源代码:
点击运行
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Fmpq教程(fmpq.com)</title> <style> div { color: blue; } div#five { color: red; } </style> <script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script> </head> <body> <div id="one"></div> <div id="two"></div> <div id="three"></div> <div id="four"></div> <div id="five"></div> <script> $(function () { var arr = [ "one", "two", "three", "four", "five" ]; var obj = { one: 1, two: 2, three: 3, four: 4, five: 5 }; $.each( arr, function( i, val ) { $( "#" + val ).text( "我的是 " + val + "." ); // 在 "three" 之后将停止运行 return ( val !== "three" ); }); $.each( obj, function( i, val ) { $( "#" + i ).append( document.createTextNode( " - " + val ) ); }); }) </script> </body> </html>
运行结果