单击表格 TD 单元格内部时是否可以弹出 Facebox 对话框

发布于 2024-08-22 13:42:58 字数 163 浏览 1 评论 0原文

当我单击 html 表格中的 td 内部时,我想弹出一个对话框。这可能吗?

https://github.com/defunkt/facebox

I want to popup a dialog facebox when I click inside a td in an html table. Is this possible ?

https://github.com/defunkt/facebox

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

意犹 2024-08-29 13:42:58

TD 作为代理...

如果您在那里有一个链接,您可以执行以下操作:

$("td").click(function(){
  $("a[rel='facebox']", this).trigger("click");
});

当然,稍微修改该代码,您可以通过单击页面上的几乎任何其他内容来调用任何链接的 Facebox。基本上,td 元素充当您的代理。如果您单击它,它会触发单击能够打开 Facebox 的链接。

没有链接吗?没问题...

如果您没有可单击的链接,您可以创建一只苍蝇,触发单击,然后将其删除。

$("td").click(function(e){
  $("<a>") // create our link
    .click(function(e){e.stopPropagation()}) // prevent bubbling
    .attr({ // set its attributes
      'href':'/css/style.css?'+$(this).text(), // append td vals
      'rel':'facebox' // make it facebox-eligible
    })
    .appendTo(this) // append it to the td
    .facebox() // tie it to facebox
    .click() // click it
    .remove(); // remove it
});​

因此,假设我们一开始是:

<td>52</td>

我们将有一个 iframe 弹出窗口指向:/css/style.css?52

TD as a proxy...

If you have a link in there, you could do something like this:

$("td").click(function(){
  $("a[rel='facebox']", this).trigger("click");
});

Of course, modifying that code slightly, you could invoke facebox for any link by clicking nearly anything else on the page. Basically, the td element serves as a proxy for you. If you click it, it triggers a click on the link that will be capable of opening facebox up.

No link? No problem...

If you don't have a link to click, you could create one of the fly, trigger a click, and then remove it.

$("td").click(function(e){
  $("<a>") // create our link
    .click(function(e){e.stopPropagation()}) // prevent bubbling
    .attr({ // set its attributes
      'href':'/css/style.css?'+$(this).text(), // append td vals
      'rel':'facebox' // make it facebox-eligible
    })
    .appendTo(this) // append it to the td
    .facebox() // tie it to facebox
    .click() // click it
    .remove(); // remove it
});​

So assume we started out with:

<td>52</td>

We will have an iframe popup pointing to: /css/style.css?52.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文