Сообщение от light
|
а лучше data-id
|
<html>
<body>
<div id="id3" onclick="give(this)" data-id="3">click me before</div>
<button id = "b">
show id
</button>
<script>
function give(object) { v = object.getAttribute("data-id") }
b.onclick = function(){console.log(v)}
</script>
</body>
</html>