Jquery:
$(document).ready(function(){
$(".li").click(function() {
//If a user leaves input fields empty and tries to log in this error will be shown
if ($("#username").val().length == "" || $("#password").val().length == "")
{$(".demo1").html("hello");}
});
});
Html:
<span ></span>
<a href="#" target="_self" id="lin">Log in</a>
On Click, the text appears and suddenly disappears. I don't want the text to disappear at all.
CodePudding user response:
It's the target attribute creating the issue every click reloads the page itself which causes a refresh of the whole code because jquery code runs once the document has finished loading because of $(document).ready(function(){});.The solution is to remove the target attribute or change its value.
CodePudding user response:
Also, the problem could be that you forgot to add "#" or the path to the next page in "href" attribute.