Reputation: 3
I'm trying to call percentValue
from CSS #number1
and have it run in the function in place of the absolute number which can usually be found after "percent":
. I'm not really sure how it works and any help would be amazing.
(function($) {
$(function() {
var percentValue = document.getElementById('number1');
/* thermometers with config */
$('.thermometer').thermometer({
percent: percentValue,
speed: 'slow'
})
});
})(jQuery);
Updated Code (Answered)
(function($) {
$(function() {
var percentValue = $('#number1').text()
/* thermometers with config */
$('.thermometer').thermometer({
percent: percentValue,
speed: 'slow'
})
});
})(jQuery);
Upvotes: 0
Views: 71
Reputation: 61904
var percentValue = document.getElementById('number1');
Currently this code is selecting the HTML element not the value it contains
Assuming number1 is a textbox or something, you can do:
var percentValue = document.getElementById('number1').value;
or (using jQuery):
var percentValue = $("#number1").val();
Upvotes: 1