jquery remove html elements inside variable (jquery object)

前端 未结 3 1830
滥情空心
滥情空心 2021-01-04 11:28

Inside HTML I have this DIV:


// usually one thumb imag
相关标签:
3条回答
  • 2021-01-04 12:05

    if You want to remove the whole html. then you can use empty()method

    $(".teaser").empty();
    

    if you are removing image only. then

    $(".teaser").find("img").remove();
    
    0 讨论(0)
  • 2021-01-04 12:08

    No need for html()

    var teaser = $(".teaser").find("img").remove();
    

    EDIT:

    Try this:

    var teaser = $(".teaser").clone();
    teaser.find("img").remove()
    // use teaser
    
    0 讨论(0)
  • It's late, but try this $('img',$('.teaser')).remove().end().clone()

    0 讨论(0)
提交回复
热议问题