English 中文(简体)
在一款内替换所有(......)期间
原标题:Replace all (.) periods within a paragraph

我试图用文号取代所有期间。 采用每种方法只能取代标语中的第一期,而不是全部。 我也试图使各界内部的时期被忽视,而不是取而代之,因此,我的法典打断了这些联系。 谁能帮助?

$( div.post ).each(function(){
    var $h = $(this);
    $h.html( $h.html().replace(  . ,  <span class="period">&deg;</span>  ) );
});

Edit: I should have mentioned, I want to retain the period class which makes it tricky.

最佳回答
var span = $( <span class="period">°</span> ).get(0);

$( p, p * ).each(function (index,element) {
    $.each(element.childNodes, function (index,node) {
        if (node.nodeType == 3) {
            $.each(node.nodeValue.split( . ), function (index,fragment) {
                if ( index > 0 ) {
                    element.insertBefore(span.cloneNode(true),node);
                }
                element.insertBefore(document.createTextNode(fragment),node);
            });
            element.removeChild(node);
        }
    });
});

解决这个问题。 关键的想法是在关于“特性”的一段内将每一文本节点的内容分开,将每一部分变成新的案文节点,然后将新案文节点与包含各文本之间编号的序号。

问题回答

采用<代码>g(全球)旗帜的栏目,应努力取而代之:

$h.html( $h.html().replace(/./g,  <span class="period">&deg;</span>  ) );

固定标签内不配对时间是一个更困难的问题,因为定期表述在超文本文件内没有等级的感觉。 我认为,最好的做法是,通过该项目内的所有分项目进行再分析,因为这些分项目的超文本目标重新瞄准,代之以,如果它是一个固定要素的话,就加以利用。





相关问题
getGridParam is not a function

The HTML: <a href="javascript:void(0)" id="m1">Get Selected id s</a> The Function: jQuery("#m1").click( function() { var s; s = jQuery("#list4").getGridParam( selarrrow )...

selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

jQuery cycle page with links

I am using the cycle plugin with pager functionality like this : $j( #homebox ) .cycle({ fx: fade , speed: fast , timeout: 9000, pager: #home-thumbs , ...

jquery ui dialog opens only once

I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.

jConfirm with this existing code

I need help to use jConfirm with this existing code (php & Jquery & jAlert). function logout() { if (confirm("Do you really want to logout?")) window.location.href = "logout.php"; } ...

Wrap text after particular symbol with jQuery

What I m trying to do, is wrap text into div inside ll tag. It wouldn t be a problem, but I need to wrap text that appears particularly after "-" (minus) including "minus" itself. This is my html: &...

热门标签