关于jquery 里的字符串拼接解决思路
关于jquery 里的字符串拼接
小弟初学javascript,我想把下面定义的 getUser_id()的返回值拼接到 url:'../panel?a=getcustomerlist&user_id=', User_id后面,请问代码怎么写?
------解决思路----------------------
<table id="dg" class="easyui-datagrid" title="用户列表"
data-options="
singleSelect:true,
collapsible:true,
fitColumns:true,
height:$(window).height() - 100,
nowrap: true,
url:'../panel?a=getcustomerlist&user_id=',
method:'get'"
toolbar="#toolbar"
pagination="true"
>
function getUser_id(){
return $.cookie('user_id');
}
小弟初学javascript,我想把下面定义的 getUser_id()的返回值拼接到 url:'../panel?a=getcustomerlist&user_id=', User_id后面,请问代码怎么写?
------解决思路----------------------
<!DOCTYPE html>
<html>
<head>
<script src="http://www.w3school.com.cn/jquery/jquery-1.11.1.min.js">
</script>
<script>
$(document).ready(function() {
function getUser_id() {
// return $.cookie('user_id');
return "xxxxxx";
}
var t = $("#dg").attr("data-options").replace(/(.*)(url.*?)', (.*)/, '$1$2' + getUser_id() + '\',$3');
$("#dg").attr("data-options", t);
document.write($("#dg").attr("data-options"));
});
</script>
</head>
<body>
<table id="dg" class="easyui-datagrid" title="用户列表"
data-options="
singleSelect:true,
collapsible:true,
fitColumns:true,
height:$(window).height() - 100,
nowrap: true,
url:'../panel?a=getcustomerlist&user_id=',
method:'get'"
toolbar="#toolbar"
pagination="true"
>
</table>
</body>
</html>