Gordy Colonna Gordy Colonna - 2 months ago 8
CSS Question

How to use window-width to change a href

How do I use Jquery's window-width to change a hyper link?

if ($(window).width() < 992) {
//go to facebook.com
}else{
//go to google.com
}


any idea on how to change my href using jquery ?

Answer
if ($(window).width() < 992) {
  $("#anchor-tag-id").attr("href", "http://www.facebook.com")
}else{
  $("#anchor-tag-id").attr("href", "http://www.google.com")
}