问题
Im trying to change a sibling of a div element and this is the statement i used
$('.edit').click(function(){
this.siblings('.innerInfo').html("success");
});
It keeps throwing the <HTMLDivElement> has no method 'siblings'
exception, and i really cant figure out why. I've initiated jQuery and ive started the script on document.ready
thanks for your help!
回答1:
Use $(this)
instead of this
.
回答2:
You're should reference $(this) like:
$('.edit').click(function(){
$(this).siblings('.innerInfo').html("success");
});
来源:https://stackoverflow.com/questions/6229198/htmldivelement-has-no-method-siblings