Created
November 28, 2013 08:34
-
-
Save pramithkm/7688841 to your computer and use it in GitHub Desktop.
Get data attribute link and open in a new window.
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
| <html> | |
| <head> | |
| <title> | |
| Window Test | |
| </title> | |
| </head> | |
| <body> | |
| The Window Test | |
| <div id="mylink" data-link="http://www.google.com">Google</a> | |
| <div id="mydiv"> | |
| <select id="myoptions"> | |
| <option data-href="http://www.google.com">Google</option> | |
| <option data-href="http://www.yahoo.com">Yahoo</option> | |
| </select> | |
| </div> | |
| </div> | |
| <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> | |
| <script type="text/javascript"> | |
| /* | |
| $('#mylink').click(function() { | |
| alert($(this).attr('data-link')); | |
| window.open($(this).attr('data-link')); | |
| });*/ | |
| $( document ).ready(function() { | |
| $('#myoptions').change(function(ev) { | |
| window.open($(this).find('option:selected').data('href')); | |
| ev.preventDefault(); | |
| }); | |
| }); | |
| </script> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment