jquery从变量中删除html元素

LeB*_*eau 4 html jquery dom

我把html保存在一个变量中

var  itinerary =  $('.events_today').html() ;
Run Code Online (Sandbox Code Playgroud)

我有很多html和一个我想删除的按钮.它的id为"myButton".如何从保存在变量中的html中删除它

fca*_*ran 10

我建议这种做法

var itinerary = $('.events_today')
                .clone(true)       /* get a clone of the element and from it */
                .find('#myButton') /* retrieve the button, then */
                .remove()          /* remove it, */
                .end()             /* return to the previous selection and */
                .html() ;          /* get the html */
Run Code Online (Sandbox Code Playgroud)