久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

      1. <legend id='mAWv3'><style id='mAWv3'><dir id='mAWv3'><q id='mAWv3'></q></dir></style></legend>
      2. <tfoot id='mAWv3'></tfoot>
        <i id='mAWv3'><tr id='mAWv3'><dt id='mAWv3'><q id='mAWv3'><span id='mAWv3'><b id='mAWv3'><form id='mAWv3'><ins id='mAWv3'></ins><ul id='mAWv3'></ul><sub id='mAWv3'></sub></form><legend id='mAWv3'></legend><bdo id='mAWv3'><pre id='mAWv3'><center id='mAWv3'></center></pre></bdo></b><th id='mAWv3'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='mAWv3'><tfoot id='mAWv3'></tfoot><dl id='mAWv3'><fieldset id='mAWv3'></fieldset></dl></div>
          <bdo id='mAWv3'></bdo><ul id='mAWv3'></ul>

        <small id='mAWv3'></small><noframes id='mAWv3'>

        在jQuery中將逗號添加到數字

        add commas to a number in jQuery(在jQuery中將逗號添加到數字)
        • <i id='zLmt5'><tr id='zLmt5'><dt id='zLmt5'><q id='zLmt5'><span id='zLmt5'><b id='zLmt5'><form id='zLmt5'><ins id='zLmt5'></ins><ul id='zLmt5'></ul><sub id='zLmt5'></sub></form><legend id='zLmt5'></legend><bdo id='zLmt5'><pre id='zLmt5'><center id='zLmt5'></center></pre></bdo></b><th id='zLmt5'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='zLmt5'><tfoot id='zLmt5'></tfoot><dl id='zLmt5'><fieldset id='zLmt5'></fieldset></dl></div>

          <small id='zLmt5'></small><noframes id='zLmt5'>

            <tbody id='zLmt5'></tbody>

                <bdo id='zLmt5'></bdo><ul id='zLmt5'></ul>

                <tfoot id='zLmt5'></tfoot>
                • <legend id='zLmt5'><style id='zLmt5'><dir id='zLmt5'><q id='zLmt5'></q></dir></style></legend>
                  本文介紹了在jQuery中將逗號添加到數字的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  限時送ChatGPT賬號..

                  我有這些號碼

                  109998094456

                  如果需要的話,我要做的就是在正確的位置添加一個逗號,所以它看起來像這樣

                  And all i want to do is add a comma in the right place if it needs it so it looks like this

                  10,9998,094456

                  這些都在像這樣的 p 標簽中 <p class="points">10999</p> 等等.

                  These are all within a p tag like this <p class="points">10999</p> etc.

                  可以嗎?

                  我在其他帖子的幫助下在這里嘗試過 http://jsfiddle.net/pdWTU/1/ 但似乎無法讓它工作

                  I've attempted it here with the help of other posts http://jsfiddle.net/pdWTU/1/ but can't seem to get it to work

                  謝謝

                  杰米

                  更新

                  搞砸了一點,并設法在這里弄清楚 http://jsfiddle.net/W5jwY/1/

                  Messed around a bit and managed to figure it out here http://jsfiddle.net/W5jwY/1/

                  打算看看新的全球化插件,以獲得更好的方法

                  Going to look at the new Globalization plugin for a better way of doing it

                  謝謝

                  杰米

                  推薦答案

                  適用于所有瀏覽器,這就是你所需要的.

                  Works on all browsers, this is all you need.

                    function commaSeparateNumber(val){
                      while (/(d+)(d{3})/.test(val.toString())){
                        val = val.toString().replace(/(d+)(d{3})/, '$1'+','+'$2');
                      }
                      return val;
                    }
                  

                  感謝正則表達式,將其寫得簡潔明了.這是直接的 JS,但你可以像這樣在 jQuery 中使用它:

                  Wrote this to be compact, and to the point, thanks to regex. This is straight JS, but you can use it in your jQuery like so:

                  $('#elementID').html(commaSeparateNumber(1234567890));
                  

                  $('#inputID').val(commaSeparateNumber(1234567890));
                  

                  但是,如果您需要更清潔、更靈活的東西.下面的代碼將正確修復小數,刪除前導零,并且可以無限使用.感謝評論中的@baacke.

                  However, if you require something cleaner, with flexibility. The below code will fix decimals correctly, remove leading zeros, and can be used limitlessly. Thanks to @baacke in the comments.

                    function commaSeparateNumber(val){
                     val = val.toString().replace(/,/g, ''); //remove existing commas first
                     var valRZ = val.replace(/^0+/, ''); //remove leading zeros, optional
                     var valSplit = valRZ.split('.'); //then separate decimals
                      
                     while (/(d+)(d{3})/.test(valSplit[0].toString())){
                      valSplit[0] = valSplit[0].toString().replace(/(d+)(d{3})/, '$1'+','+'$2');
                     }
                  
                     if(valSplit.length == 2){ //if there were decimals
                      val = valSplit[0] + "." + valSplit[1]; //add decimals back
                     }else{
                      val = valSplit[0]; }
                  
                     return val;
                    }
                  

                  在你的 jQuery 中,像這樣使用:

                  And in your jQuery, use like so:

                  $('.your-element').each(function(){
                    $(this).html(commaSeparateNumber($(this).html()));
                  });
                  

                  這里是 jsFiddle.

                  這篇關于在jQuery中將逗號添加到數字的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  Browserify, Babel 6, Gulp - Unexpected token on spread operator(Browserify,Babel 6,Gulp - 傳播運算符上的意外令牌)
                  Is it possible to pass a flag to Gulp to have it run tasks in different ways?(是否可以將標志傳遞給 Gulp 以使其以不同的方式運行任務?)
                  Why do we need to install gulp globally and locally?(為什么我們需要在全局和本地安裝 gulp?)
                  How to run Gulp tasks sequentially one after the other(如何一個接一個地依次運行 Gulp 任務)
                  Visual Studio 2015 crashes when opening Javascript files(打開 Javascript 文件時 Visual Studio 2015 崩潰)
                  Detect FLASH plugin crashes(檢測 FLASH 插件崩潰)

                    <tbody id='W29qz'></tbody>
                  <legend id='W29qz'><style id='W29qz'><dir id='W29qz'><q id='W29qz'></q></dir></style></legend>
                  <tfoot id='W29qz'></tfoot>

                  <i id='W29qz'><tr id='W29qz'><dt id='W29qz'><q id='W29qz'><span id='W29qz'><b id='W29qz'><form id='W29qz'><ins id='W29qz'></ins><ul id='W29qz'></ul><sub id='W29qz'></sub></form><legend id='W29qz'></legend><bdo id='W29qz'><pre id='W29qz'><center id='W29qz'></center></pre></bdo></b><th id='W29qz'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='W29qz'><tfoot id='W29qz'></tfoot><dl id='W29qz'><fieldset id='W29qz'></fieldset></dl></div>
                      <bdo id='W29qz'></bdo><ul id='W29qz'></ul>
                      • <small id='W29qz'></small><noframes id='W29qz'>

                            主站蜘蛛池模板: 亚洲九九| 精品在线一区 | 国内精品在线视频 | 一区二区国产在线 | 久草成人 | av中文网 | 欧美精品中文 | 国产黄色免费网站 | 国产婷婷色一区二区三区 | 欧美一级免费看 | 日韩中文在线 | 亚洲国产精品一区二区三区 | 成人免费一级 | 国产精品爱久久久久久久 | 99精品热视频 | 一区二区在线 | 久久精品中文字幕 | 免费一级片 | 99国产精品久久久久 | 久久久久久久久久影视 | 亚洲高清在线 | 青青草华人在线视频 | 国产aa | 91在线精品一区二区 | 亚洲精品成人 | 成人精品一区亚洲午夜久久久 | 亚洲国产一区二区三区在线观看 | 亚洲精品大全 | 奇米超碰 | 亚洲啪啪一区 | 久久久新视频 | 亚洲精品一区在线观看 | 伊人春色成人网 | 欧美日韩手机在线观看 | 欧美日本一区二区 | 国产伦精品一区二区三区四区视频 | 中文在线一区 | 亚洲网站在线观看 | 人人草天天草 | 久久专区 | 久久99精品久久久久久秒播九色 |