문제

을 추가하고 싶 h323:number 스타일을 연결하는 고층 연락처할 수 있도록 링크를 클릭하여 다이얼 IP 전화...

Html 내가 찾는 것은:

<table>
  <tbody>
    <tr>
      <th>Phone</th>
      <td>+44 (0)1123 1231312<span>Work</span></td>
    </tr>
    <tr>
      <th></th>
    <td>+44 (0)777 2342342<span>Other</span></td>
    </tr>
  </tbody>
</table>

기본적으로 나가고 싶은 풀 수 있는가에 td 시작하는 44,스트립으로 공간과 스틱 링크에서 내부의 범위는 다음과 같 href

h323:4411231231312  

즉은 제거함으로 0 에서 부류입니다.

어떤 도움이 될 것입 greatfully 받은 다음과 같습니다.

(1)나는 어떻게 맞 td 이 포함된+\d\d 번호?(2)어떻게 사용하는 선택기를 제외 기간은 다음과 같은 기능을 제공합니다.에서 번호를 td (3)무엇을 정규 표현식을 사용해야 하을 정리하수 위해 href?

도움이 되었습니까?

해결책

이 가까이 있어야 당신이 필요합니다.

$('tbody td').each(function() {
    // match a sequence of digits, parentheses and spaces
    var matches = $(this).text().match(/[ \d()]+/);

    if (matches) {
        // remove the spaces and stuff between parentheses
        var href = 'h323:' + matches[0].replace(/\s|\(.*?\)/g, '');
        var link = $('<a/>').attr('href', href);

        $('span', this).append(link);
    }
});

시는 경우 span's 콘텐츠를 시작으로 자리에 포함됩니다 경기;이것이 가능성이 필요했습니까?

다른 팁

여기에는 최종 그리스 몽키는 스크립트 유용할 수 있는 사람을 위해...

// ==UserScript==
// @name          HighRise Dialler
// @namespace     
// @description   Adds a CALL link to HighRise Contacts.
// @include       https://*.highrisehq.com/*
// @require       http://code.jquery.com/jquery-latest.min.js
// ==/UserScript==

(function(){

GM_xmlhttpRequest({
   method: "GET",
   url: "http://jqueryjs.googlecode.com/files/jquery-1.2.6.pack.js",
   onload: run
});

function run(details) {

   if (details.status != 200) {
       GM_log("no jQuery found!");
       return;
   }

   eval(details.responseText);
   var $ = jQuery;

   //do something useful here....

   $('table td').each(function() {
       var matches = $(this).text().match(/^\+*?[\d\(\) ]+/);

       if (matches) {
         var href = 'h323:' + matches[0].replace(/\+44|\+|\s|\(|\)/g, '');
         var link = $(' <a>CALL<a/>').attr('href', href);
         $(this).find('span').append(link);
       }
   });

}

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