Can someone assist me with adding validation in jQuery
? I'm stuck and need help solving this problem.
$(function(){
$("#btn").click(function(){
var b=prompt("Enter your link");
$("a").attr("href",b);
if($("b").val()=='')
{
var con=confirm("Please Enter your link");
if(con==true)
{
var b=prompt("Enter your link");
$("a").attr("href",b);
}else
{
var pr=confirm("Please Enter your link");
}
}
});
The provided html code is also shown below:
<html>
<head>
<script type="text/javascript" src="jquery-3.3.1.js"></script>
</head>
<body>
<div id="div1">
<a href="https://www.facebook.com"><h3>Facebook</h3></a>
<img src="1.jpg" alt="My Images">
</div>
<button id="btn">Attribute(a)</button>
</script>
</body>
</html>
I'm eagerly waiting for solutions, thank you.