许多人已经熟悉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