passing variable value to href argument in anchor tag

后端 未结 6 930
[愿得一人]
[愿得一人] 2021-01-25 12:35

how to pass the variable value to href argument in anchor tag.




        
6条回答
  •  清歌不尽
    2021-01-25 13:06

    When your Javascript is executed, the a tag might not exist yet.

    Use:

    $(document).ready(function(){
        var id = "10";
        $('#a_tag_id').attr('href','http://www.google.com&jobid='+id);
    });
    

    Also, it should be #a_tag_id to match the id.

提交回复
热议问题