使用jQuery实现显示文字气球的提示

发布于 2011-05-15 | 更新于 2020-09-20

为了使页面效果更绚丽,可以使用文字气球的提示功能,在jQuery中,可以使用简单的几条语句实现。

这里实现一个文字气球提示,在页面的按钮上点击时,该按钮的右边会向下展开一个提示信息框。再次点击,该信息框收起。

首先是编写HTML页面,基本代码如下:

http://www.itzhai.com:当我们使用搜索引擎时发现会有自动提示的功能,那么,它是怎么实现的呢?在jQuery中结合Ajax可以很容易实现自动完成的功能。 下面就在jQuery中使用Ajax提交post请求,让服务器端返回自动完成的数据显示在相应的div中。
配合下面的CSS样式显示为一个箭头的按钮;
为提示框。

CSS代码如下:

.content_read_more {
width:25px;
height:100px;
float:left;
display:inline;
position:relative;
}
.read_more_arrow{
width:20px;
height:20px;
float:left;
margin-top:40px;
margin-left:2px;
cursor:pointer;
background:url(…/images/question_arrow1.png-itzhai) no-repeat;
}
.more_tips {
display:none; /首先隐藏提示区块/
position:absolute;
left:20px;
top:40px;
width:300px;
height:200px;
background:url(…/images/readmore_tips.png-itzhai) no-repeat;
}
.more_tips div{
width:260px;
height:160px;
margin:20px;
line-height:20px;
overflow:auto;
}

以下是Javascript代码:

$(‘.read_more_arrow’).click(function(event){
$(this).next().slideToggle(“slow”);
});

效果图如下:

[caption id=“attachment_424” align=“aligncenter” width=“430” caption=“jQuery实现显示文字气球提示”]jQuery实现显示文字气球提示[/caption]

本文作者: arthinking

本文链接: https://www.itzhai.comballoon-using-jquery-to-achieve-the-prompt-display-text.html

版权声明: 版权归作者所有,未经许可不得转载,侵权必究!联系作者请加公众号。

×
IT宅

关注公众号及时获取网站内容更新。