Prefer using JQuery .
<head>
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
</head>
For Url parsing see this as a reference
// If URL is http://www.somedomain.com/account/search?filter=a#top
window.location.pathname // /account/search
// For reference:
window.location.host // www.somedomain.com (includes port if there is one)
window.location.hostname // www.somedomain.com
window.location.hash // #top
window.location.href // http://www.somedomain.com/account/search?filter=a#top
window.location.port // (empty string)
window.location.protocol // http:
window.location.search // ?filter=a
Use this method to retrieve the parameters
var getUrlParameter = function getUrlParameter(a) {
var d = window.location.search.substring(1),
c = d.split("&"),
e, b;
for (b = 0; b < c.length; b++) {
e = c[b].split("=");
if (e[0] === a) {
return e[1] === undefined ? true : decodeURIComponent(e[1])
}
}
};
Then use a simple check and apply css using JQuery
if(getUrlParameter("lname") === 'lname'){
$(".fname").css({display:'none'});
$(".lname").css({display:'block'});
}