Dodanie onclicka na wiersz tabeli za pomocą jQuery

0

Czy jest mi ktoś w stanie powiedzieć, czy ten zapis jest zły?:

$("#tableResult").find('tbody')
                .append($("<tr onclick="location.href = '@(Url.Action("ShowDetails", "DetailsController"))'">")
                    .attr('id', 'rowTable' + rowId)

Całą metoda:

function appendResultToTable(advertisementsList) {
        $("#tableResult tbody").html('');

        for (let advertisementIndex in advertisementsList) {
            const rowId = advertisementIndex;
            $("#tableResult").find('tbody')
                .append($("<tr onclick="location.href = '@(Url.Action("ShowDetails", "DetailsController"))'">")
                    .attr('id', 'rowTable' + rowId)
                .append($('<td>')
                    .append($('<p>')
                        .addClass("columnNameAdvertisement")
                            .append(advertisementsList[advertisementIndex].Name)))
                .append($('<td>')
                    .append($('<p>')
                        .append('Stan: ' + advertisementsList[advertisementIndex].Condition)))
                .append($('<td>')
                    .append($('<p>')
                        .append('Cena: ' + advertisementsList[advertisementIndex].Price + ' zł')))
                .append($('<td>')
                    .append($('<p>')
                        .append('tel. ' + advertisementsList[advertisementIndex].PhoneNumber)))
                );
        }
    }

W konsoli pokazuje się błąd: Uncaught SyntaxError: Unexpected end of input. Występuje on przy onclick="location.href =

0
table,#btn{ 
	float:left;
	width:100px;
}
<body style="background:grey">

<table>
	<caption>My Table</caption>
	<tbody>
	</tbody>
</table>

<button id="btn">BTN</button>
var id_row=0;
function create_row(e){ 
	id_row++;
	var tr = document.createElement('tr');
	tr.id = 'rowTable'+id_row;
	 
	document.querySelector('tbody').appendChild(tr);
	var td = document.createElement('td');
	var el_td = document.getElementById('rowTable'+id_row).appendChild(td);
	
	var p = document.createElement('p');
	p.setAttribute('class','columnNameAdvertisement');
	p.innerText = 'Hello';
	el_td.appendChild(p);
	
	
	tr.addEventListener('click',function(){ 
		location.href = 'http://duckduckgo.com';
	},false);
}

document.getElementById('btn').addEventListener('click',create_row,false);
</body>

1 użytkowników online, w tym zalogowanych: 0, gości: 1