I have an html page with several hyperlinks on it that share the same id but have a custom property linkID that differs. I know it is not a good practice but that is not something I can change at this point. I need to open a modal dialog box whenever a link is clicked. For that I am using JQuery. Now I need to pass the linkID property to the Jquery function. I tried using $("#hlk1").attr("LinkID") and $(this).attr("LinkID") but neither worked. It comes up as "undefined".
<html>
<head>
<script src="Script\jquery-2.2.0.js"></script>
<script src="Script\jquery-ui-1.8.24.js"></script>
<script>
$( document ).ready(function() {
$("#hlk1").click(function(){
var linkId=$("#hlk1").attr("LinkID");
// initialize dialog
var dlg = $("#dialog").dialog({
autoOpen: false, height: 500, width: 350
});
// load content and open dialog
dlg.load('page2.html?id=' + linkId).dialog('open');
});
});
</script>
</head>
<body>
<a href="#" id="hlk1" linkID="305">Click here</a>
<a href="#" id="hlk1" linkID="890">Click here</a>
<div id="dialog">
</div>
</body>
</html>
data-linkIDintead oflinkID.