有谁知道如何监听鼠标事件,例如 CLICK 或 HOVER,以便当我单击或悬停任何元素时,它会在第二个浏览器中发生相同的情况?抱歉没有包含代码。
<script>
// creating a new websocket
var socket = io.connect('http://localhost:8000');
// on message recived we print the new data inside the #container div
socket.on('notification', function (data) {
$("p").click(function () {
alert("Hello");
//or change the color
$(this).css({"color": "red"});
});
var usersList = "<div id='aaa'>";
$.each(data.users, function (index, user) {
usersList += "<p>" + user.users + "</p>";
});
usersList += "</div>";
$('#container').html(usersList);
});
</script>
<p>Click me!</p>