In my project, I have a set of div blocks each identified by a unique numerical id.
For instance: https://i.sstatic.net/lYod8.png
One of the tasks in my project is to select the 29th element following a specific chosen element. For example, if I choose the first div with id 1
, then I should be able to select the div with id 30
. Here's how I've tried to achieve this starting with the first div:
let int = parseInt($('.blockattribute').first().attr('id')) + 29;
$('#' + toString(int);
However, running this code results in the following error:
Uncaught Error: Syntax error, unrecognized expression: #[object Undefined]
Even though executing $('#30');
works perfectly fine and selects the desired div. So, what could be causing the issue?