Reputation: 5568
How do I do this? I have a function which is passed the ID of a link. I need to write my function something like:
function areYouSure(id){
$('.sure' + id).html('blah blah blah');
}
The div is called "sure". How do I pass in the ID to the jquery object? This doesn't work.
Upvotes: 0
Views: 7179
Reputation: 18420
The . is for class accessor use #
like this:
function areYouSure(id){
$('#' + id).html('blah blah blah');
}
if you have all elements with class="sure" inside a <div>
element with different id then do it like this:
function areYouSure(id){
$('div#'+ id + '.sure').html('blah blah blah');
}
Upvotes: 1
Reputation: 16752
Try:
function areYouSure(id){
$('#' + id).html('blah blah blah');
}
Since you are passing the id, you can just look up that element via that id.
Upvotes: 1