Reputation: 429
I am trying to show a Progress Bar depending on the name. I have given the Progress Bars an id with the name and with a class "progressbar." For example, $('#John.progressbar') displays the Progress Bar for John. But, if I use the variable result instead nothing works.
function progress(json,name){
var result = "'" + "#" + name + "." + "progressbar" + "'";
$('result').progressbar({
value: json
});
}
When I do console.log it even shows the exact name but for some reason $('result').progressbar
doesn't work.
Upvotes: 0
Views: 496
Reputation: 150253
You are not using the result variable, you are using 'result'
string...
var result = "#" + name + ".progressbar";
$(result).progressbar({
You wrote:
$('result')...
Notes:
#
is for id selector not for name selector.'
in javascript
is for start-end strings indicator. it's just like "
in C#\java
or most other languages you're familiar with.Upvotes: 2
Reputation: 33865
You are not setting the result-variable as the selector, if that is what you intend. You set the selector as a string with the text result
. Try this instead:
var result = "#" + name + ".progressbar";
$(result).progressbar({
value: json
});
Upvotes: 1
Reputation: 2417
That's because you are just creating a string.
To select the element, you need to use:
var result = $("#" + name);
Upvotes: 1