如何使用jQuery永久删除div [英] how to permanenlty remove a div using jQuery

查看:90
本文介绍了如何使用jQuery永久删除div的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使用jQuery从HTML中删除某个div元素,我看到了这个 http://virtser.net/inettuts/这是 http://james.padolsey.com/javascript/的演示inettuts-with-cookies/,他通过添加Cokkiee支持来保留小部件位置来扩展了代码功能.

此代码可很好地用于移动编辑,折叠或展开窗口小部件.它将所有内容保存在Cookie中,但是对于删除而言,此方法不起作用.它删除了小部件,但由于代码中存在div元素,因此当我尝试将其保存在cookie中时,它不会保存已删除的项目

解决方案

jQuery不适合从页面上永久删除元素,因为它是无状态的.

它是javascript客户端与DOM交互的包装器.从理论上讲,您可以让它根据特定用户在页面加载后可能具有的可读cookie从DOM中删除元素,但是当服务器端编码无需花费太多精力即可处理时,这是不理想的.

I was trying to remove a certain div element from my HTML using jQuery I saw this Use jquery to remove a div with no children, the jquery remove methods work perfectly fine but the problem is of Persistence,

Actually i want to permanently remove that div for that person, i was storing this in cookies but the problem is this remove method doesn't actually remove the code so when I parse through the code to store it using the cookies i store the removed code also. is there any way i can achieve a permanent removal for particular person??

Thanks Pranay

Since many people are confused here is what I was trying to achieve http://virtser.net/inettuts/ this was demo of http://james.padolsey.com/javascript/inettuts-with-cookies/ where he extended functionality of his code by adding Cokkiee support to retain the widget positions.

This code works fine for moving editing and collapse or expanding widget. It saves everything in cookie but for delete this does't work. It delete the widget but when i try to save it in cookie since the div element is present in code it does't save the deleted item

解决方案

jQuery isn't ideal for permanent removal of elements from a page as it's stateless.

Its a client side wrapper for javascript to interact with the DOM. While in theory, you can have it remove elements from the DOM based on readable cookies a particular user may have after a page has loaded, it's not ideal when server side coding could handle this without much effort.

这篇关于如何使用jQuery永久删除div的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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