jQuery append if doesn't exist

前端 未结 3 2088
你的背包
你的背包 2020-12-20 16:48

I would like to append a div only if it\'s not already there. I am trying with this but it doesn\'t work:

$(\'#method_id\').on(\'change\', funct         


        
3条回答
  •  南笙
    南笙 (楼主)
    2020-12-20 17:44

    the inner if should be if ($('#column_message').next('div').length===0) or if(!$('#column_message').next('div').length)

提交回复
热议问题