FeRo Posted March 11, 2013 Share Posted March 11, 2013 Hey! I tried this code: <div value="1" ondblclick="createWindow(this.value)" class="button"></div> It's not important what the function createWindow() does, but the "this.value" is just not getting the value "1". It keeps saying that "value" is undefined and I don't know why! It may have to do with some other part of the code, so I was just wondering if this should work... Thank You! Link to comment Share on other sites More sharing options...
jeffman Posted March 11, 2013 Share Posted March 11, 2013 'value' is not a normal property of a div. In such a situation, this should work: this.getAttribute('value') Unfortunately, it will not validate. If that matters, there is a way to create custom attributes: <div data-value="1" ondblclick="createWindow(getAttribute('data-value'))" class="button"></div> Any attribute prefixed with data- should be honored and will validate as good HTML. Disclaimer: I don't know if all browsers implement this yet. It's a technique I don't use myself. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now