0

を含む「要約マーカー」をレンダリングする独自の cms ブログを使用する必要があります。

  1. 省略記号
  2. 動的に変化するリンク (したがって、リンクは常に異なります)
  3. 次のような静的テキスト: Click here to read more.

これは、要約マーカーが現在どのようにページにレンダリングされているかです:

<p>Content goes here....<a href="example.htm">Click here to read more.</a></p>
<p>More content goes here....<a href="anothertest.htm">Click here to read more.</a></p>
<p>Content goes here....<a href="helloworld.htm">Click here to read more.</a></p>

一方、jquery を使用してサマリー マーカーを制御したいので、次のように厳密な表示に制限されることはありません。

  1. それぞれ削除ellipsis
  2. class省略記号を含む の後に ONLY を追加hrefして、ページ上の他のリンクを更新しません。

これは、待望の期待される結果です。

<p>Content goes here.<a href="example.htm" class="readmore">Click here to read more.</a></p>
<p>More content goes here.<a href="anothertest.htm" class="readmore">Click here to read more.</a>
<p>Content goes here.<a href="helloworld.htm" class="readmore">Click here to read more.</a>

事前にご協力いただきありがとうございます。

これは私が得たものです、それは私が知っている悪いことです

$("p").html("...").remove:after.attr(".readmore").attr("href"));
4

1 に答える 1

1
$('p').each(function () {
    var textNode = $(this).find('a:last-child').addClass('readmore')[0].previousSibling;

    textNode.textContent = textNode.textContent.replace(/\.{3}\s*$/, '');
});

これがフィドルです:http://jsfiddle.net/sH2eA/

于 2013-02-15T18:19:05.033 に答える