Skip to main content
Commonmark migration
Source Link

[Fiddle][1]Fiddle

Add an additional condition after your fetch ID,

if ($(this).is(':checked')) { var id_attr_val = $(this).attr("id"); if(!$('#addtoordersdiv'+id_attr_val).length){ //append code } 

.length returns 0 if element does not exists.

Alternative to !$(elem).length you can also use $(elem).length === 0 [1]: http://jsfiddle.net/e56TY/41/

[Fiddle][1]

Add an additional condition after your fetch ID,

if ($(this).is(':checked')) { var id_attr_val = $(this).attr("id"); if(!$('#addtoordersdiv'+id_attr_val).length){ //append code } 

.length returns 0 if element does not exists.

Alternative to !$(elem).length you can also use $(elem).length === 0 [1]: http://jsfiddle.net/e56TY/41/

Fiddle

Add an additional condition after your fetch ID,

if ($(this).is(':checked')) { var id_attr_val = $(this).attr("id"); if(!$('#addtoordersdiv'+id_attr_val).length){ //append code } 

.length returns 0 if element does not exists.

Alternative to !$(elem).length you can also use $(elem).length === 0

Source Link
Shaunak D
  • 20.7k
  • 10
  • 48
  • 79

[Fiddle][1]

Add an additional condition after your fetch ID,

if ($(this).is(':checked')) { var id_attr_val = $(this).attr("id"); if(!$('#addtoordersdiv'+id_attr_val).length){ //append code } 

.length returns 0 if element does not exists.

Alternative to !$(elem).length you can also use $(elem).length === 0 [1]: http://jsfiddle.net/e56TY/41/