JSFiddle - React, Tailwind, and code Playground
by AndreaLigios
HTML
<div id="out">
aa
</div>
<pre>
int main()
{
printf("Hello World");
return 0;
}
</pre>
CSS
pre div:hover {
background-color: rgba(0,0,0,0.2);
}
JavaScript
var txt = $('pre').html().split("\n");
var output = "";
for(var x=0;x<txt.length-1;x++) {
output = output + "<div class='foo'>"+txt[x]+"</div>";
}
$('pre').html(output);
$(".foo").on('click',function(){
//$("#out").val("bla");
$("#out").html("selected: -> " + $(this).html());
});