How to get the parameters of an href attribute of a link from the click event object

前端 未结 4 1182
没有蜡笔的小新
没有蜡笔的小新 2021-02-15 16:37

Is there a simple way to get the parameters at the end of an href attribute of a clicked link using the click event object?

I have some jQuery code that looks like this:

4条回答
  •  迷失自我
    2021-02-15 17:14

    Yes, you can use the .search property of the link...

    alert( this.search );
    

    DEMO: http://jsfiddle.net/sHqmF/


    To get rid of the ?, just .slice() it...

    this.search.slice(1)
    

    DEMO: http://jsfiddle.net/sHqmF/1/

提交回复
热议问题