Reputation: 1165
I am targeting dynamic div
s for that I made a code
if ($("#" + selector_name "#" + name + add_count).size() == 0) {
var p = "<div id = '" + name + add_count + "' class='progressbar' data-perc='0'><div class='bar'><span></span></div><div class='label-up'><span></span></div><div class='mi-avtr-cnt'></div><div class='clear'></div></div>";
$(".mitxt").append(p);
}
How can I target div
s dynamically . The problem is with line "#" + selector_name "#" + name + add_count
Upvotes: 0
Views: 176
Reputation: 294
"#" + selector_name "#" + name + add_count
this selector is not a valid selector(And this is a syntax error).
A valid id selector is '#' + your_element_id
use '#' + name + add_count
as selector should solve your problem
Upvotes: 0
Reputation: 113375
You have a syntax error because a +
is missing:
if ($("#" + selector_name + "#" + name + add_count).size() == 0) { ... }
^ -- This was missing
Also note that ids are supposed to be unique in document, so a div can only have one id (that is also unique). You may want to do $("#" + selector_name + ",#" + name + add_count)
(selecting two elements with different ids).
Upvotes: 1