www.webdeveloper.com
Results 1 to 3 of 3

Thread: [RESOLVED] Add custom attributes to input element

  1. #1
    Join Date
    Apr 2012
    Posts
    10

    resolved [RESOLVED] Add custom attributes to input element

    Can I add any custom attributes on an input element?
    so If I have a regular checkbox

    Code:
    <input type='checkbox' name='mycheckbox1' > my checkbox
    be able to add attributes to use in javascript. Such as


    Code:
      <script language='javascript'>
    function doIt2(formname) {
      alert (formname.mycheckbox1.special);
    }
    </script>
      </head>
      <body>
    
    <input type='checkbox' name='mycheckbox1' special='xxxxx' onclick="doIt2(this)"> my checkbox 
       
      </body>
    </html>
    However this throws an error.
    Is something like this possible?

    thanks

  2. #2
    Join Date
    Sep 2008
    Location
    Akron, OH
    Posts
    1,111
    I'm always up for networking with fellow web professionals. Connect with me on LinkedIn if you like!

  3. #3
    Join Date
    Nov 2007
    Posts
    409
    Here's an example of using a custom attribute on a select box option.
    http://www.jasondahlin.com/2011/codi...tom-values.asp

    Basically, you use selector.getAttribute("special")

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles