문제

나는 이것이 까다로운 일이라고 생각하지만, 누군가가 그것을 해결할 수 있다면 나는 매우 감동하고 매우 감사합니다.

기존 마크 업은 다음과 같습니다 (내가 바꿀 수없는 경우, 그렇지 않으면 쉬운 문제가되고 직접 해결할 수 있습니다!):

<a title="1 topics" href="http://localhost/tags/amis/">amis</a> (1) 
<a title="2 topics" href="http://localhost/tags/amis/">amis</a> (2) 
<a title="1 topics" href="http://localhost/tags/amis/">amis</a> (1) 
<a title="3 topics" href="http://localhost/tags/amis/">amis</a> (3) 

내가하고 싶은 것은 괄호와 내부의 값 ([WildCard value])를 잡고 자르고 <A> 태그 내부에 <Span>에 싸인 것입니다.

그래서 이것이 제가 후에 다음과 같습니다.

<a title="1 topics" href="http://localhost/tags/amis/">amis <span>(1)</span></a>

다시, 누군가 아이디어가 있다면 ... 감사합니다!

도움이 되었습니까?

해결책

이 시도

여기 데모

$('a').each( function(){

   var $this = $(this);
   var textEl = this.nextSibling;
   var spanEl = $('<span />').text(textEl.data);
   $this.append( spanEl );
   $(textEl).remove();

});
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top