Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
128
rated 0 times [  135] [ 7]  / answers: 1 / hits: 23580  / 13 Years ago, tue, october 25, 2011, 12:00:00

When I open my page at http://www.mywebsite.com/ where I have this jQuery code :



$('#locSlideButton2').click(function() {

});


I'd like, clicking on the locSlideButton2 element, add an hash (such as #example) to the url, without make any redirect.



How can I do it?


More From » jquery

 Answers
142

Using plain old vanilla JS:



window.location.hash='example';


MDN on window.location


[#89454] Sunday, October 23, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
madalynn

Total Points: 342
Total Questions: 95
Total Answers: 106

Location: Turkmenistan
Member since Sat, Apr 16, 2022
2 Years ago
;