<HTMLDivElement> has no method 'siblings'

你离开我真会死。 提交于 2019-12-19 19:44:06

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!