2013-02-11 74 views
0

這裏,
是我有一個問題與需要刪除與JS/CSS

<script type="text/javascript"> 

    //<![CDATA[ 

     $('#blocked_file_extensions').popover({ 
     'placement': 'bottom', 
     "title": "Blocked Extensions", 
     "content": "These filetypes will be blocked:`<br>` exe, vbs, pif, scr, bat, cmd, com, cpl, mp3, avi" 
    }); 

    //]]> 
    </script> 

後直接這樣一句話:「這些文件類型將被阻止:」代碼你會發現一個<br>標籤。我試圖用JS刪除<br>,但我似乎無法瞄準它。我無法訪問這部分代碼,我只能使用JS或CSS來更改/刪除項目。

我已經嘗試了一些刪除和替換功能,沒有運氣。

謝謝。

+0

什麼插件提供了'.popover()'jQuery的擴展?這個插件生成的標記對於'
'是必需的。 – 11684 2013-02-11 16:16:16

+1

內容呈現後,使用瀏覽器的檢查器查看它所在DOM中的位置。這應該有助於你瞄準這個元素。 – 2013-02-11 16:22:51

回答

0

我會看看試圖覆蓋您的js代碼中的選項。以前沒有使用過酥料餅,但according to the docs you can do something like this

$("#blocked_file_extensions").popover(
    'setOption' 
    , 'content' 
    , "These filetypes will be blocked: exe, vbs, pif, scr, bat, cmd, com, cpl, mp3, avi" 
); 
0

你似乎使用twitter bootstrap .popover

你可能會破壞酥料餅,並用所需的選項重新定義它..

<script type="text/javascript"> 
//<![CDATA[ 

$('#blocked_file_extensions').popover('destroy'); 
$('#blocked_file_extensions').popover({ 
     'placement': 'bottom', 
     "title": "Blocked Extensions", 
     "content": "whatever content you want ..." 
    }); 

//]]> 
</script> 
0

這裏是你如何解決這個問題...

從原始腳本創建一個修改後的腳本,並刪除原來的。

代碼

<script type="text/javascript"> 
    function fixScript() { 
     // Get all the scripts in the page 
     var scripts = document.getElementsByTagName('script'); 

     for(var i = 0; i < scripts.length; i++) { 
      // Find the script we need 
      if(scripts[i].childNodes[0] != undefined) { 
       if(scripts[i].childNodes[0].textContent.indexOf("<br>") !== -1) { 
        // Get the code from the script 
        newData = scripts[i].childNodes[0].textContent.replace("<br>", ""); 

        // Remove the old script 
        scripts[i].parentNode.removeChild(scripts[i]); 

        // Create a new script with fixed data 
        var s1 = document.createElement("script"); 
        s1.type = "text/javascript"; 
        s1.textContent = newData; 
        var s = document.getElementsByTagName("script")[0]; 
        s.parentNode.insertBefore(s1, s); 

        // Stop 
        break; 
       } 
      } 
     } 
    } 
</script> 

輸出

<script type="text/javascript"> 
    //<![CDATA[ 

     $('#blocked_file_extensions').popover({ 
     'placement': 'bottom', 
     "title": "Blocked Extensions", 
     "content": "These filetypes will be blocked:`` exe, vbs, pif, scr, bat, cmd, com, cpl, mp3, avi" 
    }); 

    //]]> 
</script>