我正在设计一个学习管理系统中的课程,并且希望使特定班级中的所有图像都可单击,因此单击照片可打开该图像的全分辨率版本。

现在,它看起来像这样:

<img class="question-image" alt="" src="https://d16smq18f8amlc.cloudfront.net/26154/assessment/879087_1.jpg">


我想把它变成这样:

<a href="https://contentlive.s3.amazonaws.com/26154/page/f0b69777.jpg" target="_blank">
    <img src="https://contentlive.s3.amazonaws.com/26154/page/f0b69777" style="height: 333px; width: 500px;">
</a>


基本上,我想将图像转换为图像的全分辨率版本的超链接。这可能吗?

最佳答案

你可以做这样的事情

<!doctype html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>on demo</title>
    <script src="https://code.jquery.com/jquery-1.10.2.js"></script>
</head>
<body>

    <img class="question-image" alt="" src="http://cdn-careers.sstatic.net/careers/Img/logos/logo-socareers.svg?v=16f4bcd961f9" />

    <script>
        $(".question-image").click(function () {
            window.open('http://stackoverflow.com/', '_blank');
        });
    </script>

</body>
</html>


为各个网址创建函数并传递参数

10-08 13:50
查看更多