Reputation: 20090
I am dynamically creating and generating their id's to be something like hidden1234
.
In the below Javascript code, var hid
is retrieved properly by document.getElementById
. But the jQuery line below has a syntax error. How can I retrieve this element by Id using jQuery?
var hid = document.getElementById('hidden'+id);
var hidden = $("#'hidden'+id");
Upvotes: 0
Views: 49
Reputation: 7771
It's just a simple typo:
var hidden = $('#hidden'+id);
You want to select an element with the id 'hidden' + id
. The according CSS / jQuery selector therefore looks like '#hidden' + id
.
Upvotes: 4