久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放AV片

<center id="vfaef"><input id="vfaef"><table id="vfaef"></table></input></center>

    <p id="vfaef"><kbd id="vfaef"></kbd></p>

    
    
    <pre id="vfaef"><u id="vfaef"></u></pre>

      <thead id="vfaef"><input id="vfaef"></input></thead>

    1. 站長資訊網(wǎng)
      最全最豐富的資訊網(wǎng)站

      js怎么替換html標簽

      在js中,可以利用replace()函數(shù)配合正則表達式“/<[^<>]+>/g”來替換html標簽,語法格式“stringObject.replace(/<[^<>]+>/g,'')”。replace()可以替換一個與正則表達式匹配的子串。

      js怎么替換html標簽

      本教程操作環(huán)境:windows7系統(tǒng)、javascript1.8.5版、Dell G3電腦。

      js替換html標簽

            function  filter(text) {             var reg = /<[^<>]+>/g;//1、全局匹配g肯定忘記寫,2、<>標簽中不能包含標簽實現(xiàn)過濾HTML標簽             text = text.replace(reg, '');//替換HTML標簽             return text;         };

      相關(guān)函數(shù)說明:

      replace() 方法用于在字符串中用一些字符替換另一些字符,或替換一個與正則表達式匹配的子串。

      語法

      stringObject.replace(regexp/substr,replacement)
      參數(shù) 描述
      regexp/substr

      必需。規(guī)定子字符串或要替換的模式的 RegExp 對象。

      請注意,如果該值是一個字符串,則將它作為要檢索的直接量文本模式,而不是首先被轉(zhuǎn)換為 RegExp 對象。

      replacement 必需。一個字符串值。規(guī)定了替換文本或生成替換文本的函數(shù)。

      返回值:

      • 一個新的字符串,是用 replacement 替換了 regexp 的第一次匹配或所有匹配之后得到的。

      補:在angularJS中使用過濾器過濾富文本數(shù)據(jù)

      app.filter('qxhtml', function () {         return function (text) {             var reg = /<[^<>]+>/g;             text = text.replace(reg, '');             text = text.replace(/ /ig, '');             if (text.length > 50) {                 text = text.substring(0, 50) + "...";             }             return text;         };     });

      使用過濾器

      <div class="desc">      {{y.Description| qxhtml}} </div>

      贊(0)
      分享到: 更多 (0)
      網(wǎng)站地圖   滬ICP備18035694號-2    滬公網(wǎng)安備31011702889846號