How to make scoll high when loading page?
I'm trying to do this, but to no avail!
File: messaging.php
$('.chatUsuariosLista').click(function() {
idUsuario = this.id;
$("#chatMsg").load('inc_chatMensagens.php?de='+idUsuario+'¶='+$("#para").val());
$("#para").val(idUsuario);
$('#chat2').attr({scrollTop: $('#chat2').attr('scrollHeight')});
});
I tried to put the code $('#chat2').attr({scrollTop: $('#chat2').attr('scrollHeight')});
inside the file inc_chatMessages.php, but it also does not work.
File inc_chatMessages.php
<div id="chat2">
<ul>
<?php while ($row = $rs->fetch_assoc()) {?>
<?php if ($_GET['de'] == $row['de']) {?>
<li>
<div class="bubble">
<span class="personName">Cliente:</span> <br>
<span class="personSay"><?php echo $row['msg']; ?></span> <br>
<span class="time"><?php echo $row['data']; ?></span>
</div>
</li>
<?php }else{ ?>
<li>
<div class="bubble2">
<span class="personName2">Você:</span> <br>
<span class="personSay2"><?php echo $row['msg']; ?></span><br>
<span class="time2"><?php echo $row['data']; ?></span>
</div>
</li>
<?php } ?>
<?php } ?>
</ul>
</div>