I wanna display a progressbar
based of what the data- value of that wrapper div
is.
<div class="photo webdesignTag" data-progress="20">
<div class="photo-image"></div>
<h2>Example1</h2>
<div class="progressbar"></div>
</div>
<div class="photo photoshopTag" data-progress="50">
<div class="photo-image"></div>
<h2>Example2</h2>
<div class="progressbar"></div>
</div>
$(".photo").each(function() {
var ProgressBarContainer = $(this).attr("data-progress");
$(this).children("h2").html(ProgressBarContainer);
$(this).children(".progressbar").progressbar({
value: ProgressBarContainer
});
Can anyone help me?
The issue is because you use attr()
to get the data-progress
value. This returns a string, whereas the value
property is expecting an integer. If you retrieve the value using data()
it will be correctly typed:
$(".photo").each(function() {
var $el = $(this);
var progressBarValue = $el.data("progress");
$el.children("h2").html(progressBarValue);
$el.children(".progressbar").progressbar({
value: progressBarValue
});
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.