Skip to content Skip to sidebar Skip to footer

Using Javascript To Alter Attributes In A Mvc Web Application

I am trying to increase the progress of the progress bar by a fixed parameter irrespective of the current value. However, I am not able to extract the current value using the .valu

Solution 1:

You just need to use parseInt:

<scripttype="text/javascript">functionincrease() {
        var pwidth = parseInt(document.getElementById("pb1").style.width);
        console.log(pwidth);  // output to console
        pwidth += 10;
        var str = pwidth + "%";
        document.getElementById("pb1").style.width = str;
    }
</script>

Note: In future you can just use console.log(pwidth); for debugging - will show value on console in the F12 Dev tools console. In the original case it was showing as undefined.

Post a Comment for "Using Javascript To Alter Attributes In A Mvc Web Application"