Saturday 15 March 2014

javascript - Increase and decrease a data attar depending on the size -


I currently hhave

when you remove the data attribute data-the best way to reduce the size What is a div? When you remove the fields and when you remove the fields, the data-size increases basically.
my html

  & lt; Ul id = "variants" & gt; & Lt; A href = "#" class = "add_options" data-id = "70281696560900" & gt; Add more & lt; / A & gt; & Lt; / Ul & gt;   

Thanks.

HTML:

  & lt; Ul id = "variant" data-size = "0" & ​​gt; & Lt; A href = "#" class = "add_options" data-id = "70281696560900" & gt; Add more & lt; / A & gt; & Lt; / Ul & gt; Number of rows: & lt; Span id = "count" & gt; 0 & lt; / Span & gt;   

JS:

  $ ('Add_options'). Input type = "text" id = "prop_name" class = "prop_name" placeholder = ("click", function () {$ ('# variants'). (& Lt; div class = "some_id" "Property Name" & gt; & lt; a href = "#" class = "remover" & gt; Remove & lt; / a & gt; & lt; / div & gt; '); var size = parseInt ($ ('' Data-size ''), 10) + 1; $ ('# variants') .attr ("data-size", size); $ ("# count"). Text ( Shape);}); $ ('#Variants') ('Click', '.remover', function () {$ (this) .closest ('. Some_id'). Hide (); var size = parseInt ($ ('# variants ("data-size", size) ; $ ("# Count"). Text (size);} ("data-size"), 10) - 1; $ ('# variants').);   

< / P>

No comments:

Post a Comment