Javascript Class : create and destroy elements -
i'm new javascript classes, or lack of real support classes.
in case, i'd create function can create , destroy dom elements. i'm ok creating elements destroying them bit trickier.
how can call destroy without having provide id?
function workzone() { this.create = function(id) { $('<div>', { id: id, class: 'work-zone' }).appendto('body'); } this.destroy = function(id) { $(id).remove(); } } $(function() { var zone = new workzone(); zone.create(); zone.destroy(); });
use jquery instead of creating custom code:
http://api.jquery.com/category/manipulation/
you full browser support , optimal code , ability these sorts of dom manipulations lots of different kinds of selectors.
Comments
Post a Comment