jQuery从变量中删除html元素 [英] jquery removing html element from variable

查看:53
本文介绍了jQuery从变量中删除html元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已将html保存在变量中

I have html saved in a variable

var  itinerary =  $('.events_today').html() ;

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

I have lots of html and one button I want to remove. It has the id "myButton". How can I remove it from the html saved in my variable

推荐答案

我建议采用这种方法

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 */

这篇关于jQuery从变量中删除html元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆