How can I create link that does nothing? - html

I want to create a link that does NOTHING, it means that its a fake link
Im trying with onclick="mijava();return false;" but it scrolls up in the website
How can I do it?

javascript:
document.getElementById("nothing").addEventListener("click", function(event){
event.preventDefault()
});
html:
<a id="nothing" href="#">Link</a>
JSFiddle

"javascript:void(0)" to href attribute, the <a> tag will do nothing.

This won't do anything.
Link

Do you test it that?
link

You can use CSS to style it like a link and you probably don't want to use an anchor tag if it's not going to act like one.
See this answer: How to make an anchor tag refer to nothing?

Related

my href link isn't working with my button in my html document

so basically I have this button that doesn't work, when I hover over it my cursor doesn't change and when I click it nothing happens, here's the buttons line of code:
<button href="dwr.php" class="dwrbutton fas fa-address-card"> <div class="dwrtext">DWR</div></button>
Href is not a button attribute.
https://www.w3schools.com/tags/tag_button.asp
Use a form with the link as action, or try a <A> tag with styling
add button class to anchor tag
<div class="dwrtext">DWR</div>
If you want to set a href on your button simply wrap it with an anchor element.
Your code should look something like this:
<button href="dwr.php" class="dwrbutton fas fa-address-card">DWR</button>
If you really need to use the button-tag, then you should look here for a solution to your problem. Especially preferred if you need the button-tag within a form.
If you don't care how the link is implemented, then I would personally use an a-tag, which you can then design according to your preferences, also like a button.
Have fun and good luck!

How to make html button redirect like an anchor tag

I am new to stackoverflow and I want some quick help here. Actually I am in learning phase now and I want to know how to visit a new page on button click. Like <a href='mypage'></a> That means, if I am on page 1 I want to go to page 2.
FOR EXAMPLE:
if we use anchor tag and add href value it will redirect us to new page
<a href='mypage'>Click ME</a>
But i need to know if we use button how can i redirect to specific page like anchor tag!
How can I achieve this?
Sorry if this requirement is too low for you, but its kind of first step to me.
Any help would be appreciable.
Thanks!
Way 1 :
<button onclick="location.href = 'www.example.com';">www.example.com</button>
Way 2 :
<button id="button">www.example.com</button>
<script type="text/javascript">
document.getElementById("button").onclick = function () {
location.href = "www.example.com";
};
</script>
Try in this way.
<input type='button' value='redirect' class="btn" onclick="document.location.href='www.google.com';"/>
You can either:
Wrap button tags with <a href>
<a href='mypage'><button>Click ME</button></a>
Wrap <a href> with button tags
<button><a href='mypage'>Click ME</a></button>

button href is ignoring everything after question mark

I have this button
<button href="account.html?gto=4356">go to</button>
On click it redirects to ./account.html?# though i was expecting ./account.html?gto=4356.
Why is it ignoring everything after the question mark and how can I make this work?
Button tag does not support href attribute. instead use a tag and css design to make it look like a button.
go to
Hope it will help you.
You can do it with Javascript
<button onclick='goto()'>go to</button>
<script>
function goto(){
location.replace("account.html?gto=4356");
}
</script>
You Have to do it like this
<button>go to</button>
I hope this works for you! regards

href link to nowhere

I've got a hover effect under "Latest Playlists"
https://phuzz.superhi.com/
but would like to make the link unclickable or not to go anywhere.
I've tried the return false and couple of other options but it just makes the page scroll to the top and reload?
This is what I've got at the moment:
<em>2.</em><i> INTO THE FIRE BY SUCK</i> <img src="rs-13160-102513-black-flag-623-1382724540.jpg">
Thanks!
If you don't want it clickable, don't use <a> anchor in the first place.
Use <span></span> tag instead.
Please add below code in href=" ".
href="javascript:void(0);"
This is work for me. Please try it.

Add link code to this bottom code

Haw can i add a link to this code ?
<span style="background-color:#81d742;">Title</span>
this code is for a bottom in a website and i want it to have a link .
Thank you
You are allowed to put a tags inside span
<span style="background-color:#81d742;">Title</span>
Why would you need a <span>? You can just change the tag to a <a> tag:
<a style="background-color:#81d742;" href="http//mysite.com">Title</a>
You can simply do so by using anchor tag, i.e. a tag
For example, if you wish to link google.co, you can do so by following commands,
Google