Javascript-форум (https://javascript.ru/forum/)
-   jQuery (https://javascript.ru/forum/jquery/)
-   -   Скрипт не видит, что элемент с определенным id существует (https://javascript.ru/forum/jquery/68313-skript-ne-vidit-chto-ehlement-s-opredelennym-id-sushhestvuet.html)

pashin76 08.04.2017 15:55

Скрипт не видит, что элемент с определенным id существует
 
$("input:checkbox").bind("change", function () {
			$("input:checkbox").map(function(){
				if(this.checked)
					{
					alert($("#sel_" + this.id).length + " - " + "#sel_" + this.id);
					if ($("#sel_" + this.id).length==0) $("#popup_selected_filters").append('<span id="sel_' + this.id +'">' + this.id + '</span>');
					}
				
				});
			});


$("#sel_" + this.id).length всегда равен 0, даже если элемент существует

pashin76 08.04.2017 17:02

разобрался, проблема была из-за квадратных скобок в id


Часовой пояс GMT +3, время: 22:54.