How can I change html using Go?

I have searched for a solution that changes the html dynamically. Like this jQuery:

It should be possible using goquery, but I cannot find the syntax for this. Or is it possible without goquery?

I tried this code using goquery without success:

func addhtml() {
	doc, err := goquery.NewDocument("")
	if err != nil {


I have now done som tests.

  1. AJAX gives only data - no HTML
  2. Storing all contents in the table gives data - no HTML
  3. iFrame gives you both data and HTML and you can do a simple database lookup from an id (note that you need a bigger screen 1800px+)


<tr data-id={{.post_id}}>
<iframe id="subwin" src=""></iframe>
<script>const url = 'c_post?id=';</script>


const selected = table.getElementsByClassName('selected')
table.onclick = sel;
function sel(row) {
  if ( > 0) {
    if (selected[0]) selected[0].className = ''; = 'selected';
    const el = document.querySelector('selected');
    document.getElementById('subwin').src = (url +;

Is there really no other ways to populate an area with both HTML and data without using iFrame?

Websockets may be a solution, but it seems to be overkill. Or?

Is it possible to use goquery?