如何使div可点击以打开链接?

时间:2017-09-16 04:50:42

标签: javascript css

我想将此div可点击以重定向到另一个页面?

<div aria-describedby="slick-slide12" aria-hidden="true" class="slide all-slider-category-gallery slick-slide" data-slick-index="2" role="option" style="background-image: url(); width: 280px;" tabindex="-1"></div>

2 个答案:

答案 0 :(得分:1)

将此属性添加到<div id="my-div"> <a href="http://google.com/" class="fill-div"></a> </div>

div

将网址更改为您想要的链接。

答案 1 :(得分:0)

使用Javascript:

sample_list = [2, 10, 3, 5]

x =[sample_list[0]+ sample_list[1]+ sample_list[2]+ sample_list[3]]

b = len (sample_list)

avrage = x / b

print("This is result of list", avrage)

使用<div onclick="location.href='http://google.com/';" style="cursor: pointer;"</div> 标记使div可点击:

&#13;
&#13;
a
&#13;
#my-div {
    background-color: #f00;
    width: 200px;
    height: 200px;
}
a.fill-div {
    display: block;
    height: 100%;
    width: 100%;
    text-decoration: none;
}
It is possible to make a link fill the entire div which gives the appearance of making the div clickable.
&#13;
&#13;
&#13;