1. 功能: 取得整數亂數、字串型態整數亂數、十六進制亂數
2. 風格: 無
3. 依賴: 無
4. 用途: 產生隨機整數、亂數取名或產生GUID使用。
5. 函式:
5.1 random: 取得亂數整數,參數:length -最大位數,1<length<9,預設5.
5.2 randomString: 取得亂數字串,參數{length - 最大位數,不足自動補0,1<length<9,預設5}.
5.3 randomHex: 取得16進制亂數,參數{length - 最大位數,不足自動補0,l1<length<9,預設5}.
6. 範例:
<script src="http://code.jquery.com/jquery-1.6.2.min.js" type="text/javascript"> <script type="text/javascript" src="js/jquery.random.js"></script> <script type="text/javascript"> $(function () { $('.RunRandom').click(function () { $('.ResultRandom').val($(this).random()); }); $('.RunRandomString').click(function () { $('.ResultRandom').val($(this).randomString()); }); $('.RunRandomHex').click(function () { $('.ResultRandom').val($(this).randomHex()); }); }); </script>
7. 後續改善: 無
沒有留言:
張貼留言