开发者

how to permanenlty remove a div using jQuery

开发者 https://www.devze.com 2023-02-02 08:19 出处:网络
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 Persi

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 fun开发者_Go百科ctionality 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.


to remove it permanently you have to use serverside language for example php


You could revert the process and add the DIV for specific users instead, leaving the data in the .js instead.


To remove DIV "permanently" you have to use serverside lang. The logic is simple:

  1. Remove DIV from HTML
  2. Save some info about user and removed DIV in cookies
  3. In serverside script you have to get cookie and check did user disable any div or not. If he did your script should skip DIV generation
0

精彩评论

暂无评论...
验证码 换一张
取 消