I am trying to assign div id to a variable in jQuery .
var tbdiv = null;
tbdiv= $('#mydiv');
But this is throwing error in my jQuery file as ‘ Invalid argument ‘.
I am trying to do the following code which is in javascript
var tbdiv =document.getElementById('mydiv');
You can use
attr:I would though simply do:
to assign id.
If you MEANT assigning element itself, this should work fine:
Or with vanilla JS: