(function ($) { $("#comment").html($("#comment").html().replace(/>>(\d)/g,"" + ">>$1" + "")); console.log(document); func(0); function func(n) { var l = 0; $(".anc").on("mouseenter", function (e) { if (l == 0) {//ポップは一つだけ l += 1; $(".container").prepend("
"); $(".pop" + n).css({//ポップの修飾 position: 'absolute', border: '1px solid #ccc', 'background-color': 'white', top: '0', left: '0', 'z-index': 1, width:'50%', }) var anc = $(this).attr("href"),//アンカーのhref取得 res = "" + $("#" + anc).html() + "
番号メッセージ
",//id検索 x = e.pageX, y = e.pageY; $(".pop" + n) .append(res) .css({ transform: "translate3d(" + x + "px," + y + "px,0)" }) .show(); $(".pop" + n).on("mouseleave", function () { $(this).remove(); }) func(n + 1); } }); } })(jQuery);