经典论坛's Archiver

forcs 发表于 2008-8-28 22:55

一个关于jQurery的小问题

文档一
<!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>
<script src="http://jqueryjs.googlecode.com/files/jquery-1.2.6.js" type="text/javascript">
</script>
<script type="text/javascript" language="javascript">
$(document).ready(function() {
        $('#button').toggle(function() {
                        $(this).text('SHOW');
                },function() {
                        $(this).text('HIDE');
                });
        });
</script>
<style type="text/css">
<!--
* {
        padding:0px;
        margin:0px;
}

body {
        font:12px Verdana, Arial, Helvetica, sans-serif;
        color:#FF9900;
}

#main {
        padding:5px;
        margin:0px auto;
        width:700px;
}

#label {
        padding:10px;
        margin:10px;
        width:200px;
}

.button {
        padding:5px;
        margin:5px;
        border:1px solid #99CC00;
        font:12px Geneva, Arial, Helvetica, sans-serif;
        font-weight:bolder;
        width:100px;
        float:right;
        text-align:center;
}

.clearSpace {
        clear:both;
}

.content {
        padding:5px;
        margin:5px;
        font:12px Verdana, Arial, Helvetica, sans-serif;
        font-weight:bolder;
        color:#0099CC;
        word-wrap:break-work;
        display:block;
        overflow:inherit;
}
-->
</style>
</head>

<body>
<div id="main">
        <div id="label"><h1>Hello World!</h1></div>
    <div class="button" id="button"><h3>HIDE</h3></div>
    <div class="clearSpace"></div>
    <div class="content">
            <p>文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本<span class="more">...</span></p>
        <p>文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本文本</p>
    </div>
<div class="clearSpace"></div>
</div>
</body>
</html>

为何但点击按钮激活了Click事件后,.button类的样式就失效了呢?

[[i] 本帖最后由 forcs 于 2008-8-28 22:57 编辑 [/i]]

danirkl 发表于 2008-8-29 07:17

使用哪个 .html() 试一试

comasp 发表于 2008-8-29 16:11

没流失吧

你用firebug看下就知道了


主要你页面上有
<h3>HIDE</h3>


然后你换调后  变为 show 了


你应该为
<h3>show </h3>

页: [1]



Powered by Discuz! Archiver 6.1.0  © 2001-2007 Comsenz Inc.