Jump to content

html data-* with js


L8V2L

Recommended Posts

If you're talking about attributes, data attributes are a standard supported way to add additional data to an element, rather than trying to fit data into an existing set of attributes that don't match what the actual data is.

  • Like 1
Link to comment
Share on other sites

If you're talking about attributes, data attributes are a standard supported way to add additional data to an element, rather than trying to fit data into an existing set of attributes that don't match what the actual data is.

So in lamen terms, it just away to make your own attribute.(please a yes or no for clarity)Is that all it's go for?
Link to comment
Share on other sites

That's what it's for, yes. In previous versions of HTML, adding your own attributes would cause validation to fail.

Thank you for clairty! :-)... Can I alter it with js to make it an event then js a static key value pair?
Link to comment
Share on other sites

I don't understand your question.

Can I alter it with js to make it more than just a storage for data? Can I turn it into an event? Can I assign it a function that will expand it's functionality? Making it more than just a static data storage for holding value?
Link to comment
Share on other sites

You can't create a new attribute and have it automatically treated as an event handler without writing all of the code to monitor elements and set up those handlers. Ideally, if you are creating event handlers then you use Javascript to attach those events instead of putting them in HTML attributes. You can create custom events and manually dispatch them on specific elements.http://www.sitepoint.com/javascript-custom-events/

  • Like 1
Link to comment
Share on other sites

You can't create a new attribute and have it automatically treated as an event handler without writing all of the code to monitor elements and set up those handlers. Ideally, if you are creating event handlers then you use Javascript to attach those events instead of putting them in HTML attributes. You can create custom events and manually dispatch them on specific elements.http://www.sitepoint.com/javascript-custom-events/

Thanks for the link! :-) I like your post for two reason. One, is to show my appreciation. And two is in the hope of this forums allowing it's user to browse by likes. So I can reference this again.
Link to comment
Share on other sites

JSG, could you give me your knowledge on prototype and constructor function?I have question, but it's more of a discussion then a straight out asking manner.If anyone would like to do the same Davej, and the others, you are more than welcome to do so.

Link to comment
Share on other sites

JSG, could you give me your knowledge on prototype and constructor function?

Uhh.. not really. I have a job you know, I'm not just sitting here posting on a forum all day. If you have specific questions I can try to address them. I'm not going to sit here and type out an entire tutorial though.
Link to comment
Share on other sites

Uhh.. not really. I have a job you know, I'm not just sitting here posting on a forum all day. If you have specific questions I can try to address them. I'm not going to sit here and type out an entire tutorial though.

x-p <== addresses that! Edited by L8V2L
Link to comment
Share on other sites

Asking the same question more than once isn't going to get different answers.

You're absolutely right. Just got me a unhelpful response.
Link to comment
Share on other sites

If anyone cares to give you a helpful response, they will do so regardless of where your question is. Notwithstanding the fact that you're asking about XML books in a Javascript thread that doesn't have anything to do with XML.

Link to comment
Share on other sites

If anyone cares to give you a helpful response, they will do so regardless of where your question is. Notwithstanding the fact that you're asking about XML books in a Javascript thread that doesn't have anything to do with XML.

No one be in the xml thread.... But I'll try.
Link to comment
Share on other sites

Why does it stack over flow when condition is taking out:

var bar = function(num){        return (num + arguments.callee(num - 1));}var result = bar(2);console.log(result);//stack exceededvar foo = function(bar){         if(bar < 0){                    return -1;          }   else if(bar === 0){   return 1;}         else{                return(bar  + arguments.callee(bar - 1));          }}foo(2);// output 4Extra:var bar = function(args) {     var err;var actual = arguments.length;             var expected = arguments.callee.length;   switch(actual != expected){           case true:{throw err = new Error("Wrong number of arguments: expected: " +                          expected + "; actually passed " + actual);     break;}case false:{if(arguments[0] < 0){      return -1;}else if(arguments[0] === 0){return 1;}else{return (arguments[0] * arguments.callee(arguments[0] -1));break;}}}}bar(99);
Edited by L8V2L
Link to comment
Share on other sites

Why wouldn't it overflow the stack? What are you telling it to do? Think about it.

If I put a if else condition in to check for 1, 0 or less, It'll work. Why is that?I display this happening with two of the same code, but with just different names.
Link to comment
Share on other sites

Look at the code, what does it do with the check? What does it do without it?

So why don't it return 1? Or if I was decrementing by a value higher than one, why don't it return -1?Why do it return the value of the expression? (Even know expression evaluate to a value) when it recursion by invoking it self, shouldn't it return 1, or -1 if decrementing by a numeral value higher than 1.
Link to comment
Share on other sites

So why don't it return 1? Or if I was decrementing by a value higher than one, why don't it return -1?

You need to trace the code. Use a pencil and paper if you need to. What are you telling the function to return?
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...