jQuery pass specific div ID
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开发者_如何学C.
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');
}
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.
精彩评论