php - Manipulating jquery variables -
<html> <head> <style> .messboxcontent { display:none; background: rgba(0,0,0,.4); width: 400px; height: 100px; margin: 50px auto; padding: 15px;} .mess_name {display: inline-block; cursor: pointer ; vertical-align: middle; width:165px; height:35px; background:blue; bottom:0px; left:144px; margin-right: 16px} #msg_holder {overflow-x:scroll ;overflow-y: hidden; white-space: nowrap; position:fixed;height:110px; width:100%; background-color:yellow; bottom:0px;} </style> <script type="text/javascript" src="jquery.js" ></script> <script> $(document).ready( function() { done(); }); function done() { settimeout( function() { update(); done(); }, 20000); } function update() { $.getjson("fetch.php", function(data) { $.each(data.result, function(){ var message = this['message']; var name = this['name']; call(name, message); }); }); }; function call(name, message){ $("#msg_holder").append("<div class='mess_name'>" + name + "<div>"); $(".mess_test").click( function() { $('div.messboxcontent').html(' name : '+ name + ' message : ' + message); $('div.messboxcontent').fadein(); return false; }); } </script> </head> <body> <div class="messboxcontent"></div> <div id="msg_holder"></div> </doby> </html>
and fetch.php file
{"result":[{"message":"this haha","name":"haha"},{"message":"this koka","name":"koka"}]}
when ever click on blue box contain name, show latest message , name. want when click on box contain haha name want box contain message: haha,
you need use append rather html.
$('div.box').append( message );
Comments
Post a Comment