Return an Attribute Value to an Object Javascript
up vote
-1
down vote
favorite
I`need to return the attribute value of "data-animate" and "data-speed" to the object fxBalloon. In that object those string values should be passed to duration : $speedFX and name :$nameFX but comes up undefined. Please look at code below and link for reference
https://codepen.io/paul-solomon/pen/MzjYmK?editors=1111.
<div class="container">
<div class="balloon">
<div class="fxballoon" data-animate="b_layer1" data-speed="6s">
<span>sample</span>
</div>
<div class="fxballoon" data-animate="b_layer2" data-speed="5s">
<span>sample</span>
</div>
<div class="fxballoon" data-animate="b_layer3" data-speed="3s">
<span>sample</span>
</div>
</div>
</div>
//Global Var
var $elemClass = $(".balloon .fxballoon");
var fxBalloon = {
elem : $elemClass,//Class or Id
name :$nameFX, //Sets Option Name for Balloon Animation
duration : $speedFX, //Sets Option for Speed
delay : "ease-in-out", //Sets Option for Easing
count : "infinite", // sets an Infinite Loop
action : "paused", // Sets the Play or Pause Action
$nameFX: function() {
dataAnimation();
},
$speedFX: function() {
dataSpeedAnimation();
},
$animationFX: function() {
$(this).each(function() { //Iterates over the object FxController
setAnimation(this.elem,this.name,this.duration,this.delay,this.count,this.action);
});
}
};
fxBalloon.$animationFX();
// loops to get the data-speed attribute value from DOM
function dataSpeedAnimation(){
for( var i = 0; i < $elemClass.length;i++){
// console.log($elemClass[i].getAttribute("data-speed"));
$elemClass[i].getAttribute("data-speed");
}
}
// loops to get the data-animate attribute value from DOM
function dataAnimation(){
for( var i = 0; i < $elemClass.length;i++){
return $elemClass[i].getAttribute("data-animate");
}
}
// Object Construct for CSS to animate styles to DOM
function setAnimation(elem, name, duration, delay, count, action) {
$(elem).css({ "-webkit-animation": name + " "+ duration + " "+ delay + " "+ count });
$(elem).css({ "-moz-animation": name + " "+ duration + " "+ delay + " "+ count });
$(elem).css({ "-o-animation": name + " "+ duration + " "+ delay + " "+ count });
$(elem).css({ "animation": name + " "+ duration + " "+ delay + " "+ count});
$(elem).css({ "animation-play-state:": action});
}
javascript
add a comment |
up vote
-1
down vote
favorite
I`need to return the attribute value of "data-animate" and "data-speed" to the object fxBalloon. In that object those string values should be passed to duration : $speedFX and name :$nameFX but comes up undefined. Please look at code below and link for reference
https://codepen.io/paul-solomon/pen/MzjYmK?editors=1111.
<div class="container">
<div class="balloon">
<div class="fxballoon" data-animate="b_layer1" data-speed="6s">
<span>sample</span>
</div>
<div class="fxballoon" data-animate="b_layer2" data-speed="5s">
<span>sample</span>
</div>
<div class="fxballoon" data-animate="b_layer3" data-speed="3s">
<span>sample</span>
</div>
</div>
</div>
//Global Var
var $elemClass = $(".balloon .fxballoon");
var fxBalloon = {
elem : $elemClass,//Class or Id
name :$nameFX, //Sets Option Name for Balloon Animation
duration : $speedFX, //Sets Option for Speed
delay : "ease-in-out", //Sets Option for Easing
count : "infinite", // sets an Infinite Loop
action : "paused", // Sets the Play or Pause Action
$nameFX: function() {
dataAnimation();
},
$speedFX: function() {
dataSpeedAnimation();
},
$animationFX: function() {
$(this).each(function() { //Iterates over the object FxController
setAnimation(this.elem,this.name,this.duration,this.delay,this.count,this.action);
});
}
};
fxBalloon.$animationFX();
// loops to get the data-speed attribute value from DOM
function dataSpeedAnimation(){
for( var i = 0; i < $elemClass.length;i++){
// console.log($elemClass[i].getAttribute("data-speed"));
$elemClass[i].getAttribute("data-speed");
}
}
// loops to get the data-animate attribute value from DOM
function dataAnimation(){
for( var i = 0; i < $elemClass.length;i++){
return $elemClass[i].getAttribute("data-animate");
}
}
// Object Construct for CSS to animate styles to DOM
function setAnimation(elem, name, duration, delay, count, action) {
$(elem).css({ "-webkit-animation": name + " "+ duration + " "+ delay + " "+ count });
$(elem).css({ "-moz-animation": name + " "+ duration + " "+ delay + " "+ count });
$(elem).css({ "-o-animation": name + " "+ duration + " "+ delay + " "+ count });
$(elem).css({ "animation": name + " "+ duration + " "+ delay + " "+ count});
$(elem).css({ "animation-play-state:": action});
}
javascript
add a comment |
up vote
-1
down vote
favorite
up vote
-1
down vote
favorite
I`need to return the attribute value of "data-animate" and "data-speed" to the object fxBalloon. In that object those string values should be passed to duration : $speedFX and name :$nameFX but comes up undefined. Please look at code below and link for reference
https://codepen.io/paul-solomon/pen/MzjYmK?editors=1111.
<div class="container">
<div class="balloon">
<div class="fxballoon" data-animate="b_layer1" data-speed="6s">
<span>sample</span>
</div>
<div class="fxballoon" data-animate="b_layer2" data-speed="5s">
<span>sample</span>
</div>
<div class="fxballoon" data-animate="b_layer3" data-speed="3s">
<span>sample</span>
</div>
</div>
</div>
//Global Var
var $elemClass = $(".balloon .fxballoon");
var fxBalloon = {
elem : $elemClass,//Class or Id
name :$nameFX, //Sets Option Name for Balloon Animation
duration : $speedFX, //Sets Option for Speed
delay : "ease-in-out", //Sets Option for Easing
count : "infinite", // sets an Infinite Loop
action : "paused", // Sets the Play or Pause Action
$nameFX: function() {
dataAnimation();
},
$speedFX: function() {
dataSpeedAnimation();
},
$animationFX: function() {
$(this).each(function() { //Iterates over the object FxController
setAnimation(this.elem,this.name,this.duration,this.delay,this.count,this.action);
});
}
};
fxBalloon.$animationFX();
// loops to get the data-speed attribute value from DOM
function dataSpeedAnimation(){
for( var i = 0; i < $elemClass.length;i++){
// console.log($elemClass[i].getAttribute("data-speed"));
$elemClass[i].getAttribute("data-speed");
}
}
// loops to get the data-animate attribute value from DOM
function dataAnimation(){
for( var i = 0; i < $elemClass.length;i++){
return $elemClass[i].getAttribute("data-animate");
}
}
// Object Construct for CSS to animate styles to DOM
function setAnimation(elem, name, duration, delay, count, action) {
$(elem).css({ "-webkit-animation": name + " "+ duration + " "+ delay + " "+ count });
$(elem).css({ "-moz-animation": name + " "+ duration + " "+ delay + " "+ count });
$(elem).css({ "-o-animation": name + " "+ duration + " "+ delay + " "+ count });
$(elem).css({ "animation": name + " "+ duration + " "+ delay + " "+ count});
$(elem).css({ "animation-play-state:": action});
}
javascript
I`need to return the attribute value of "data-animate" and "data-speed" to the object fxBalloon. In that object those string values should be passed to duration : $speedFX and name :$nameFX but comes up undefined. Please look at code below and link for reference
https://codepen.io/paul-solomon/pen/MzjYmK?editors=1111.
<div class="container">
<div class="balloon">
<div class="fxballoon" data-animate="b_layer1" data-speed="6s">
<span>sample</span>
</div>
<div class="fxballoon" data-animate="b_layer2" data-speed="5s">
<span>sample</span>
</div>
<div class="fxballoon" data-animate="b_layer3" data-speed="3s">
<span>sample</span>
</div>
</div>
</div>
//Global Var
var $elemClass = $(".balloon .fxballoon");
var fxBalloon = {
elem : $elemClass,//Class or Id
name :$nameFX, //Sets Option Name for Balloon Animation
duration : $speedFX, //Sets Option for Speed
delay : "ease-in-out", //Sets Option for Easing
count : "infinite", // sets an Infinite Loop
action : "paused", // Sets the Play or Pause Action
$nameFX: function() {
dataAnimation();
},
$speedFX: function() {
dataSpeedAnimation();
},
$animationFX: function() {
$(this).each(function() { //Iterates over the object FxController
setAnimation(this.elem,this.name,this.duration,this.delay,this.count,this.action);
});
}
};
fxBalloon.$animationFX();
// loops to get the data-speed attribute value from DOM
function dataSpeedAnimation(){
for( var i = 0; i < $elemClass.length;i++){
// console.log($elemClass[i].getAttribute("data-speed"));
$elemClass[i].getAttribute("data-speed");
}
}
// loops to get the data-animate attribute value from DOM
function dataAnimation(){
for( var i = 0; i < $elemClass.length;i++){
return $elemClass[i].getAttribute("data-animate");
}
}
// Object Construct for CSS to animate styles to DOM
function setAnimation(elem, name, duration, delay, count, action) {
$(elem).css({ "-webkit-animation": name + " "+ duration + " "+ delay + " "+ count });
$(elem).css({ "-moz-animation": name + " "+ duration + " "+ delay + " "+ count });
$(elem).css({ "-o-animation": name + " "+ duration + " "+ delay + " "+ count });
$(elem).css({ "animation": name + " "+ duration + " "+ delay + " "+ count});
$(elem).css({ "animation-play-state:": action});
}
javascript
javascript
edited Nov 12 at 6:49
asked Nov 12 at 6:48
Paul Solomon
34
34
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
-1
down vote
var fxBalloon = {
elem : $elemClass,//Class or Id
name :"ease-in-out", //Sets Option Name for Balloon Animation
duration : "ease-in-out", //Sets Option for Speed
delay : "ease-in-out", //Sets Option for Easing
count : "infinite", // sets an Infinite Loop
action : "paused", // Sets the Play or Pause Action
$nameFX:
dataAnimation(),
$speedFX:
dataSpeedAnimation(),
$animationFX: function() {
$(this).each(function() { //Iterates over the object FxController
dataSpeedAnimation();
setAnimation(this.elem,this.name,this.duration,this.delay,this.count,this.action);
});
}
};
fxBalloon.$animationFX();
Is there any way get the values of html attributes data-animate and data-animate and apply them to the name and duration values in the object fxballoon, I have a for loop function that iterates to get attributes. I want to be able to control the duration at different speeds (eg: 6s.5s,4s) pulling from the data-speed function. same with name value in the Object(eg:b_layer1,b_layer2, b_layer3).
– Paul Solomon
Nov 12 at 14:28
instead run a loop outside the object
– Balaji V
Nov 14 at 7:04
I already have the loop outside of the object. the Object comes back undefined when I call it in the object.
– Paul Solomon
Nov 14 at 16:27
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53257120%2freturn-an-attribute-value-to-an-object-javascript%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
-1
down vote
var fxBalloon = {
elem : $elemClass,//Class or Id
name :"ease-in-out", //Sets Option Name for Balloon Animation
duration : "ease-in-out", //Sets Option for Speed
delay : "ease-in-out", //Sets Option for Easing
count : "infinite", // sets an Infinite Loop
action : "paused", // Sets the Play or Pause Action
$nameFX:
dataAnimation(),
$speedFX:
dataSpeedAnimation(),
$animationFX: function() {
$(this).each(function() { //Iterates over the object FxController
dataSpeedAnimation();
setAnimation(this.elem,this.name,this.duration,this.delay,this.count,this.action);
});
}
};
fxBalloon.$animationFX();
Is there any way get the values of html attributes data-animate and data-animate and apply them to the name and duration values in the object fxballoon, I have a for loop function that iterates to get attributes. I want to be able to control the duration at different speeds (eg: 6s.5s,4s) pulling from the data-speed function. same with name value in the Object(eg:b_layer1,b_layer2, b_layer3).
– Paul Solomon
Nov 12 at 14:28
instead run a loop outside the object
– Balaji V
Nov 14 at 7:04
I already have the loop outside of the object. the Object comes back undefined when I call it in the object.
– Paul Solomon
Nov 14 at 16:27
add a comment |
up vote
-1
down vote
var fxBalloon = {
elem : $elemClass,//Class or Id
name :"ease-in-out", //Sets Option Name for Balloon Animation
duration : "ease-in-out", //Sets Option for Speed
delay : "ease-in-out", //Sets Option for Easing
count : "infinite", // sets an Infinite Loop
action : "paused", // Sets the Play or Pause Action
$nameFX:
dataAnimation(),
$speedFX:
dataSpeedAnimation(),
$animationFX: function() {
$(this).each(function() { //Iterates over the object FxController
dataSpeedAnimation();
setAnimation(this.elem,this.name,this.duration,this.delay,this.count,this.action);
});
}
};
fxBalloon.$animationFX();
Is there any way get the values of html attributes data-animate and data-animate and apply them to the name and duration values in the object fxballoon, I have a for loop function that iterates to get attributes. I want to be able to control the duration at different speeds (eg: 6s.5s,4s) pulling from the data-speed function. same with name value in the Object(eg:b_layer1,b_layer2, b_layer3).
– Paul Solomon
Nov 12 at 14:28
instead run a loop outside the object
– Balaji V
Nov 14 at 7:04
I already have the loop outside of the object. the Object comes back undefined when I call it in the object.
– Paul Solomon
Nov 14 at 16:27
add a comment |
up vote
-1
down vote
up vote
-1
down vote
var fxBalloon = {
elem : $elemClass,//Class or Id
name :"ease-in-out", //Sets Option Name for Balloon Animation
duration : "ease-in-out", //Sets Option for Speed
delay : "ease-in-out", //Sets Option for Easing
count : "infinite", // sets an Infinite Loop
action : "paused", // Sets the Play or Pause Action
$nameFX:
dataAnimation(),
$speedFX:
dataSpeedAnimation(),
$animationFX: function() {
$(this).each(function() { //Iterates over the object FxController
dataSpeedAnimation();
setAnimation(this.elem,this.name,this.duration,this.delay,this.count,this.action);
});
}
};
fxBalloon.$animationFX();
var fxBalloon = {
elem : $elemClass,//Class or Id
name :"ease-in-out", //Sets Option Name for Balloon Animation
duration : "ease-in-out", //Sets Option for Speed
delay : "ease-in-out", //Sets Option for Easing
count : "infinite", // sets an Infinite Loop
action : "paused", // Sets the Play or Pause Action
$nameFX:
dataAnimation(),
$speedFX:
dataSpeedAnimation(),
$animationFX: function() {
$(this).each(function() { //Iterates over the object FxController
dataSpeedAnimation();
setAnimation(this.elem,this.name,this.duration,this.delay,this.count,this.action);
});
}
};
fxBalloon.$animationFX();
answered Nov 12 at 7:18
Balaji V
465
465
Is there any way get the values of html attributes data-animate and data-animate and apply them to the name and duration values in the object fxballoon, I have a for loop function that iterates to get attributes. I want to be able to control the duration at different speeds (eg: 6s.5s,4s) pulling from the data-speed function. same with name value in the Object(eg:b_layer1,b_layer2, b_layer3).
– Paul Solomon
Nov 12 at 14:28
instead run a loop outside the object
– Balaji V
Nov 14 at 7:04
I already have the loop outside of the object. the Object comes back undefined when I call it in the object.
– Paul Solomon
Nov 14 at 16:27
add a comment |
Is there any way get the values of html attributes data-animate and data-animate and apply them to the name and duration values in the object fxballoon, I have a for loop function that iterates to get attributes. I want to be able to control the duration at different speeds (eg: 6s.5s,4s) pulling from the data-speed function. same with name value in the Object(eg:b_layer1,b_layer2, b_layer3).
– Paul Solomon
Nov 12 at 14:28
instead run a loop outside the object
– Balaji V
Nov 14 at 7:04
I already have the loop outside of the object. the Object comes back undefined when I call it in the object.
– Paul Solomon
Nov 14 at 16:27
Is there any way get the values of html attributes data-animate and data-animate and apply them to the name and duration values in the object fxballoon, I have a for loop function that iterates to get attributes. I want to be able to control the duration at different speeds (eg: 6s.5s,4s) pulling from the data-speed function. same with name value in the Object(eg:b_layer1,b_layer2, b_layer3).
– Paul Solomon
Nov 12 at 14:28
Is there any way get the values of html attributes data-animate and data-animate and apply them to the name and duration values in the object fxballoon, I have a for loop function that iterates to get attributes. I want to be able to control the duration at different speeds (eg: 6s.5s,4s) pulling from the data-speed function. same with name value in the Object(eg:b_layer1,b_layer2, b_layer3).
– Paul Solomon
Nov 12 at 14:28
instead run a loop outside the object
– Balaji V
Nov 14 at 7:04
instead run a loop outside the object
– Balaji V
Nov 14 at 7:04
I already have the loop outside of the object. the Object comes back undefined when I call it in the object.
– Paul Solomon
Nov 14 at 16:27
I already have the loop outside of the object. the Object comes back undefined when I call it in the object.
– Paul Solomon
Nov 14 at 16:27
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53257120%2freturn-an-attribute-value-to-an-object-javascript%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown