开发者

line return in javascript [closed]

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 10 years ago.

im trying to make this box stay one one width at 150px but how do i get text that is retrived that is longer that that return text to the next line instead of expand the div.

       <div id="page" style="position:absolute; float:right; top:500px; right:0px; background-color:#F5F5F5; color: #F6221D; font-size:12px; width:150;">
        <h2>ShoutOut</h2>

        <form method="post" action="shout.php">
            <strong>Message:</strong>
          <input type="text" id="message" name="message" class="message" /><input type="submit" id="submit" value="Submit" />
        </form>

        <div id="shout" style="padding:0 10px 0; width:150; 开发者_如何学Goheight:170px;; overflow-y:auto;">

        </div>
    </div>

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
$(function() {

    //populating shoutbox the first time
    refresh_shoutbox();
    // recurring refresh every 15 seconds
    setInterval("refresh_shoutbox()", 15000);

    $("#submit").click(function() {
        // getting the values that user typed
        var name    = $("#name").val();
        var message = $("#message").val();
        // forming the queryString
        var data            = 'name='+ name +'&message='+ message;

        // ajax call
        $.ajax({
            type: "POST",
            url: "shout.php",
            data: data,
            success: function(html){ // this happen after we get result
                $("#shout").slideToggle(500, function(){
                    $(this).html(html).slideToggle(500);
                    $("#message").val("");
                });
          }
        });    
        return false;
    });
});

function refresh_shoutbox() {
    var data = 'refresh=1';

    $.ajax({
            type: "POST",
            url: "shout.php",
            data: data,
            success: function(html){ // this happen after we get result
                $("#shout").html(html);
            }
        });
}


There is an error in your CSS:

width:150;

should be:

width:150px;


Try adding this style to the DIV:

word-wrap:break-word;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜