許多人已經熟悉Firebug Inspect選項,它允許在加載的網頁中移動並選擇網頁元素進行檢查。JavaScript可視化元素選擇,刪除
也許有人知道任何類似的JavaScript可以做到這一點?我需要允許用戶在運行時選擇並刪除網頁元素。用戶訪問網頁,在元素上移動鼠標和選擇網頁元素,用戶點擊元素將其刪除。
任何我可以開始的參考?
問候, 托馬斯
許多人已經熟悉Firebug Inspect選項,它允許在加載的網頁中移動並選擇網頁元素進行檢查。JavaScript可視化元素選擇,刪除
也許有人知道任何類似的JavaScript可以做到這一點?我需要允許用戶在運行時選擇並刪除網頁元素。用戶訪問網頁,在元素上移動鼠標和選擇網頁元素,用戶點擊元素將其刪除。
任何我可以開始的參考?
問候, 托馬斯
我喜歡挑戰。
使用jQuery,我剛剛做了一個簡單的例子,我將如何去除元素,直觀。看看演示roosteronacid.com/visualremove。
$(function()
{
$("* :not(body)").mouseenter(function()
{
var that = $(this);
var offset = that.offset();
var a = $("<a />",
{
title: "Click to remove this element",
css: {
"position": "absolute",
"background-color": "#898989",
"border": "solid 2px #000000",
"cursor": "crosshair",
width: that.width() + 6,
height: that.height() + 2
},
offset: {
top: offset.top - 4,
left: offset.left - 4
},
click: function()
{
that.remove();
a.remove();
},
mouseleave: function()
{
a.fadeTo(200, 0, function()
{
a.remove();
});
}
});
that.after(a.fadeTo(200, 0.5));
});
});
真棒!我怎樣才能直接與你聯繫?我想討論一個問題。 – Tomas 2010-08-17 10:51:12
在這裏與我聯繫,夥伴。 – roosteronacid 2010-08-17 11:09:55
你說你喜歡挑戰;)你有什麼想法如何將UNDO添加到你的演示?比方說,我刪除了幾個對象,然後點擊撤消按鈕來恢復它們? – Tomas 2010-08-17 11:15:13
有Firebug的精簡版,螢火蟲打包爲一個javascript,把在其他瀏覽器比FF:http://getfirebug.com/firebuglite
杜佩:http://stackoverflow.com/questions/3269404/allow-users-to-select-an-arbitrary-element-on-the-page 但我喜歡這個答案好:P – 2010-08-17 13:08:47