Last active
April 3, 2017 12:08
-
-
Save kigold/95cddbf9ed7bca3e6dfe6244603986af to your computer and use it in GitHub Desktop.
Wordpress js script to get user field anf then user the value to change the the data-counter-value of a stats counter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Select Stat counter element | |
var y = document.querySelectorAll('.credit_value [data-counter-value="2000000"]'); | |
//Get user income from wp member field if id user_income | |
var user = document.querySelectorAll('#user_income .wpb_wrapper')[0]; | |
var user_income = user.innerHTML; | |
var income = user_income.split(" ")[0]; | |
income = income.replace(',', ''); | |
income = Number(income) - 1; | |
console.log(income); | |
///set the data-counter-value attribute of the stat counter to the user monthly income | |
y[0].setAttribute('data-counter-value',String(income)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment