<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style type="text/css">
*{
margin:0;
padding:0;
}
body{
font-size:12px;
}
.div{
width:465px;
border:1px solid #DCDCDC;
float:left;
}
.exp{
width:465px;
height:94px;
float:left;
line-height:25px;
overflow:hidden;
}
.fold{
width:465px;
float:left;
line-height:25px;
}
.div_a{
float:right;
}
</style>
<script>
window.onload=function()
{
var oC=document.getElementById('content');
var oA=document.getElementById('aC');
oA.onclick=function()
{
if(oC.className=="exp")
{
this.innerHTML='收起';
oC.className='fold';
}
else
{
this.innerHTML='展开';
oC.className='exp';
}
}

}
</script>
</head><body>
<div class="div">
 <div class="exp" id="content">
 福建,在周朝为七闽地,春秋以后为闽越地。秦置闽中郡,中央政权始达于福建。汉初为闽越国疆域,闽越福建——安溪.中国茶都福建——安溪.中国茶都(4张)
北迁之后,自汉始元二年(前85年)汉承认冶县、置东部都尉开始,中经东部都尉从冶县迁到章安(回浦),留下候官管理冶县,到设立南部都尉,再到建安十二年(207年)正式成立建安郡止,福建都在王朝军事管制之下。三国时属吴国,设建安郡,辖建安、南平、将乐、建平(建阳)、东平(松溪)、昭武、吴兴(浦城)以及候官、东安(南安、同安)共9县。
 </div>
 <a href="javascript:;" id="aC">展开</a>
</div>
</body>
</html>

解决方案 »

  1.   


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>无标题文档</title>
    <style type="text/css">
    *{
    margin:0;
    padding:0;
    }
    body{
    font-size:12px;
    }
    .div{
    width:465px;
    border:1px solid #DCDCDC;
    float:left;
    }
    .div_1{
    width:465px;
    height:94px;
    float:left;
    overflow:hidden;
    line-height:25px;
    }
    .div_a{
    float:right;
    }
    </style>
    <script type="text/javascript" src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
    </head>
    <script type="text/javascript">
    function zk(){
    $(".div_1").css({
    height: 'auto'
    }); 

    }
    </script>
    <body>
    <div class="div">
     <div class="div_1">
     福建,在周朝为七闽地,春秋以后为闽越地。秦置闽中郡,中央政权始达于福建。汉初为闽越国疆域,闽越福建——安溪.中国茶都福建——安溪.中国茶都(4张)
    北迁之后,自汉始元二年(前85年)汉承认冶县、置东部都尉开始,中经东部都尉从冶县迁到章安(回浦),留下候官管理冶县,到设立南部都尉,再到建安十二年(207年)正式成立建安郡止,福建都在王朝军事管制之下。三国时属吴国,设建安郡,辖建安、南平、将乐、建平(建阳)、东平(松溪)、昭武、吴兴(浦城)以及候官、东安(南安、同安)共9县。
     </div>
     <a href="javascript:zk();">展开</a>
    </div>
    </body>
    </html>
      

  2.   

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>无标题文档</title>
    <style type="text/css">
    *{
        margin:0;
        padding:0;
        }
    body{
        font-size:12px;
        }
    .div{
        width:465px;
        border:1px solid #DCDCDC;
        float:left;
        }
    .exp{
        width:465px;
        float:left;
        line-height:25px;
    border:1px red solid;
        }
    .fold{
        width:465px;
        float:left;
        line-height:25px;
    }
    .div_a{
        float:right;    }
    </style>
    <script>
    window.onload=function()
    {
        var oC=document.getElementById('content');
        var oA=document.getElementById('aC');
        var oC1=document.getElementById('content1');
        var oA1=document.getElementById('aC1');
    if(oC.innerHTML != oC.getAttribute('bc')){
    oA.onclick=function()
    {
    oC.innerHTML=oC.getAttribute('bc');
    this.style.display = 'none';
    }
    oA.style.display = 'block';
    }
    if(oC1.innerHTML != oC1.getAttribute('bc')){
    oA1.onclick=function()
    {
    oC1.innerHTML=oC1.getAttribute('bc');
    this.style.display = 'none';
    }
    oA1.style.display = 'block';
    }
         
    }
    </script>
    </head>
     
    <body>
    <div class="div">
     <div class="exp" id="content" bc="福建,在周朝为七闽地,春秋以后为闽越地。秦置闽中郡,中央政权始达于福建。汉初为闽越国疆域,闽越福建——安溪.中国茶都福建——安溪.中国茶都(4张)北迁之后,自汉始元二年(前85年)汉承认冶县、置东部都尉开始,中经东部都尉从冶县迁到章安(回浦),留下候官管理冶县,到设立南部都尉,再到建安十二年(207年)正式成立建安郡止,福建都在王朝军事管制之下。三国时属吴国,设建安郡,辖建安、南平、将乐、建平(建阳)、东平(松溪)、昭武、吴兴(浦城)以及候官、东安(南安、同安)共9县。">福建,在周朝为七闽地,春秋以后为闽越地。秦置闽中郡,中央政权始达于福建。汉初为闽越国疆域,闽越福建——安溪.中国茶都福建——安溪.中国茶都(4张)北迁之后,自汉始元二年(前85年)汉承认冶县、置东部都尉开始,中经东部都尉从冶县迁到章安(回浦),留下候官管理冶县,到设立南部都尉,再到建安十二年(207年)正式成立建安郡止,福建都在王朝军事管制之下。三国时属吴国,设建安郡,辖建安、南平、将乐、建平(建阳)、东平(松溪)、昭武、吴兴(浦城)以及候官、东安(南安、同安)共9县。</div>
     <br/>
     <a href="javascript:;" style="display:none;" id="aC">展开</a>
     <div style="height:150px;">&nbsp;</div>  <div class="exp" id="content1" bc="福建,在周朝为七闽地,春秋以后为闽越地。秦置闽中郡,中央政权始达于福建。汉初为闽越国疆域,闽越福建——安溪.中国茶都福建——安溪.中国茶都(4张)北迁之后,自汉始元二年(前85年)汉承认冶县、置东部都尉开始,中经东部都尉从冶县迁到章安(回浦),留下候官管理冶县,到设立南部都尉,再到建安十二年(207年)正式成立建安郡止,福建都在王朝军事管制之下。三国时属吴国,设建安郡,辖建安、南平、将乐、建平(建阳)、东平(松溪)、昭武、吴兴(浦城)以及候官、东安(南安、同安)共9县。">福建,在周朝为七闽地,春秋以后为闽越地。秦置闽中郡,中央政权始达于福建。汉初为闽越国疆域,闽越福建——安溪.中国茶都福建——安溪.中国茶都(4张)北迁之后,自汉始元二年(前85年)汉承认冶县、置东部都尉开始,中经东部都尉从冶县迁到章安(回浦),留下候官管理冶县,到设立南部都尉,再到建安十二年(207年)...</div>
      <br/>
     <a href="javascript:;" style="display:none;" id="aC1">展开</a>
    </div>
    </body>
    </html>
      

  3.   

    请问下 这个怎么判断文字没有超过class="exp"的时候 下面a标签隐藏  文字超过class="exp" a标签在显示
      

  4.   


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>无标题文档</title>
    <style type="text/css">
    *{
    margin:0;
    padding:0;
    }
    body{
    font-size:12px;
    }
    .div{
    width:465px;
    border:1px solid #DCDCDC;
    float:left;
    }
    .exp{
    width:465px;
    height:94px;
    float:left;
    line-height:25px;
    overflow:hidden;
    }
    .fold{
    width:465px;
    float:left;
    line-height:25px;
    }
    .div_a{
    float:right;
    }
    </style>
    <script>
    window.onload=function()
    {
    var oC=document.getElementById('content');
    var oA=document.getElementById('aC');
    if(oC.scrollHeight<=getStyle(oC,'height'))
    oA.style.display='none';
    else
    oA.style.display='block';
    oA.onclick=function()
    {
    if(oC.className=="exp")
    {
    this.innerHTML='收起';
    oC.className='fold';
    }
    else
    {
    this.innerHTML='展开';
    oC.className='exp';
    }
    }

    }
    function getStyle(obj,attr)
    {
    if(obj.currentStyle)
    return parseFloat(obj.currentStyle[attr])||0;
    return parseFloat(getComputedStyle(obj,0)[attr])||0;
    }
    </script>
    </head><body>
    <div class="div">
     <div class="exp" id="content">
     福建,在周朝为七闽地,春秋以后为闽越地。秦置闽中郡,中央政权始达于福建。汉初为闽越国疆域,闽越福建——安溪.中国茶都福建——安溪.中国茶都(4张)
    9县。 福建,在周朝为七闽地,春秋以后为闽越地。秦置闽中郡,中央政权始达于福建。汉初为闽越国疆域,闽越福建——安溪.中国茶都福建——安溪.中国茶都(4张)
    9县。 福建,在周朝为七闽地,春秋以后为闽越地。秦置闽中郡,中央政权始达于福建。汉初为闽越国疆域,闽越福建——安溪.中国茶都福建——安溪.中国茶都(4张)
    9县。
     </div>
     <a href="javascript:;" id="aC">展开</a>
    </div>
    </body>
    </html>
      

  5.   

    我觉得用Jquery里的innerHeight()方法进行对比就行
    if($("#div_1").innerHeight()<$("#div").innerHeight())
    {
    $("a").remove();
    }