简体   繁体   English

如何在href中给定数据属性的URL中添加URL参数?

[英]How do I add an URL parameter to an URL given a data attribute in the href?

I have a problem with this: 我对此有疑问:

Html HTML

<a href="#2" class="page-link" data-wpurl="?p=2" onmousedown="rwt(this)">2</a>

JS JS

rwt = function(e){
    $(".t-pageholder").load("http://mysite.asd/index.php/".data('wpurl'));
};

How can i go link http://mysite.asd/index.php?p=2 with this code? 如何使用此代码链接http://mysite.asd/index.php?p=2

Please try the following : Html 请尝试以下操作:HTML

<a href="#2" class="page-link" data-wpurl="?p=2" onmousedown="rwt(this)">2</a>

Javascript Java脚本

rwt = function(e){
    var wpurl = $(e).data('wpurl');
    $(".t-pageholder").load("http://mysite.asd/index.php/"+wpurl);
};

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM