I am trying to tick a checkbox which is inside the first cell of a tablerow.
var checkbox = $(this).find("td").eq(0);
returns an [Object object] but when I use the html() function it is clear that it returns only the code for the input element.
Is it possible to cast the variable checkbox so that I can then check it?
You’re getting
[Object object]because.eq()returns a jQuery object.You’re getting HTML code with
.html()because that is a method of the jQuery object, which returns the HTML inside an element (similar to raw Javascript.innerHTML()).To get the raw HTML DOM element from a jQuery object, you can try something like:
EDIT
But if you want to check a checkbox, you can try calling
.attr('checked', true)on a jQuery object representing the checkbox DOM element.