我需要在点击 href 链接时打开灯箱。
我尝试了以下代码,但它没有打开灯箱(网址在同一浏览器中打开)。
你能告诉我如何打开灯箱吗?
现有代码(使用 DWQA 插件创建):
<div class="dwqa-questions-list">
<div class="dwqa-question-item dwqa-status-answered">
<header class="dwqa-question-title">
<a href="https://www.web.com/question/%ed%94/">Question One</a>
</header>
</div>
<div class="dwqa-question-item dwqa-status-answered">
<header class="dwqa-question-title">
<a href="https://www.web.com/question/%ed%94%8c%/">Question Two</a>
</header>
</div>
</div>
我试过的灯箱代码:
控制台显示一个错误:
Unexpected token '<' => <!DOCTYPE html>
?>
<script language="JavaScript" type="text/javascript" src="jquery/jquery.js"></script>
<script>
(function($){
$(document).ready(function() {
$("a",".dwqa-question-title").click(
function(event) {
event.preventDefault();
var elementURL = $(this).attr("href");
$.colorbox({iframe: true,href: elementURL,innerWidth: 645,innerHeight: 509});
});
});
});
</script>
谢谢你。