using .prop() with jsdom doesn´t work

Skip to first unread message


Aug 11, 2021, 9:39:17 AM8/11/21
to jsdom
Hello together,
I am using jsdom on my node server. Everything works fine. But I have problems with using the .prop() statement to check or uncheck checkboxes. The .attr() statement is doing well.

.attr works fine:
$('#' + Id).attr(attr, value);

but .prop() doesn´t work:
$('#' + Id).prop('checked', true); 

Would be happy for some help.


Michael Schubert

Aug 11, 2021, 10:05:14 AM8/11/21
to jsdom
To clarify my post: If prop() is not supported, is there also another way to check or uncheck checkboxes? 

Domenic Denicola

Aug 11, 2021, 10:41:35 AM8/11/21

Can you post a full code sample using ?

You received this message because you are subscribed to the Google Groups "jsdom" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To view this discussion on the web visit

Michael Schubert

Aug 11, 2021, 11:03:42 AM8/11/21
to jsdom
Would be great if we can fix it without a full code sample:

My code is very simple. I have only three variables:
  1.  type to identify the type (button, checkbox, range,...).
  2.  attr (checked, min, max,...) 
  3.  value (100, true, false,...)
I am using only these few rows:

let jsdom = require("jsdom");
let dom = new jsdom.JSDOM(myHtml);
let $ = require("jquery")(dom.window);

 if(type != 'checkbox'){
    $('#' + id).attr(attr, value);
} else {
    $('#' + id).prop(attr, value);

attr() works great, but prop() doesn't work... I checked all my variables with a log. 

Variables for prop():
 $(Id_1).prop('checked', true);

Michael Schubert

Aug 11, 2021, 11:16:18 AM8/11/21
to jsdom
my html code is:

<div class="custom-control custom-switch mt-3 ml-4"> 
    <input type="checkbox" class="custom-control-input" id="id_1">

Updating the html on the client side works fine. Only on the serverside with .prop() it doesn´t work
Reply all
Reply to author
0 new messages