html code
function getQuerystring() {
var getUrlParameter = function getUrlParameter(sParam) {
var sPageURL = window.location.search.substring(1),
sURLVariables = sPageURL.split('&'),
sParameterName,
i;
for (i = 0; i < sURLVariables.length; i++) {
sParameterName = sURLVariables[i].split('=');
if (sParameterName[0] === sParam) {
return sParameterName[1] === undefined ? true : decodeURIComponent(sParameterName[1]);
}
}
};
var blog = getUrlParameter('c');
document.getElementById('detail').innerHTML = blog;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div style="border: dashed; size: auto;"><a name="divtest" href="#detail?c=active" id="test" onclick="getQuerystring()">testing</a>
</div>
<div id="detail" style="border: 2px; size: auto;"></div>
this function should display the value of c in the link but instead it displays undefined in the div.i have searched a lot and tried so many of things but nothing seems to be working. kindly guide me the right code i will be thankful to you.