gpt4 book ai didi

javascript - Razor ActionLink 打开 Colorbox

转载 作者:行者123 更新时间:2023-11-28 08:11:47 25 4
gpt4 key购买 nike

有人可以帮助我使用这个 ActionLink,我想在 Razor 中打开一个隐藏的 Div,

这是链接,

<a class='inline' href="#inline_content">Inline HTML</a>

这是脚本,

<script>
$(document).ready(function () {
$(".inline").colorbox({ inline: true, width: "50%" });
});
</script>

还有 Div,

<p><a class='inline' href="#inline_content">Inline HTML</a></p>

<div style='display:none'>
<div id='inline_content' style='padding:10px; background:#fff;'>

<p><strong>This content comes from a hidden element on this page.</strong></p>

<p>The inline option preserves bound JavaScript events and changes, and it puts the content back where it came from when it is closed.</p>

</div>
</div>

编辑

我需要用 MVC Razor 风格的 ActionLink 重新编写 HTML 链接,该代码在 HTML 中工作正常,但在 Razor 中不行。 HTML 链接发布到 Razor 中的新页面,因此我认为我需要一个 ActionLink 来发布到脚本。

<a class='inline' href="#inline_content">Inline HTML</a>

例如..

@Html.ActionLink("Inline HTML", null, null, new { Class="inline", onclick = "#inline_content();" });

最佳答案

尝试这样,

    @Html.ActionLink("Inline HTML", null, null, new { Class="inline", onclick = "Show_Div_content();" });


<script type="text/javascript">
function Show_Div_content() {
$("#inline_content").parent().show();
}
</script>

关于javascript - Razor ActionLink 打开 Colorbox,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24112802/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com