在博客園中執行本身的腳本

在頁腳Html代碼中加入:css

<!-- 運行頁面上的自定義腳本 -->
<style type="text/css">
textarea[title=js]
{ 
    display: none;
}
</style>
<script>
$(function()
{
    $('textarea[title=js]').each(function(){window.eval($(this).text())});
});
</script>

代碼簡單,你懂得,我就不說啥了。html

在界面上添加對應的元素,測試

<textarea title="js">function t1(v)
{
var dt=new Date();
var str=dt.getHours()+":"+dt.getMinutes()+":"+dt.getSeconds();
str="---------- ["+str+"] t1執行日誌 : "+v+" -----------";
  console.log(str);
$('#res').html(str);
}
</textarea>
<div id="res" style="color: red; font-weight: bold;"> 

this

 

 

點擊按鈕測試spa

 

 轉自:日誌

https://www.cnblogs.com/mq0036/p/10348687.htmlcode

相關文章
相關標籤/搜索