How to set same url for different elements

This question already has an answer here:

  • jQuery same click event for multiple elements 9 answers

  • You could set a home page variable and just use that like so

    var homePageUrl = "http://realestatecenter.bankofamerica.com/"
    

    and just pass window.location.href = homePageUrl

    you could also make it its own function like

    function redirect(path) {
     window.location.href = path
    }
    

    and then call that function in each place with the url as the argument that way at least you are sourcing everything to one function vs duplicating code

    链接地址: http://www.djcxy.com/p/83448.html

    上一篇: JQuery单击事件多个元素事件

    下一篇: 如何为不同元素设置相同的网址