我有这样的链接:
http://localhost:8162/UI/Link2.aspx?txt_temp=123abc
Run Code Online (Sandbox Code Playgroud)
我想得到价值123abc.我已经按照这个如何在JavaScript中获取查询字符串值?和
jquery从URL获取查询字符串
$(document).ready(function () {
function getUrlVars() {
var vars = [], hash;
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
for (var i = 0; i < hashes.length; i++) {
hash = hashes[i].split('=');
vars.push(hash[0]);
vars[hash[0]] = hash[1];
}
return vars;
}
function getParameterByName(name) {
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
results = regex.exec(location.search);
return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}
onload = function …Run Code Online (Sandbox Code Playgroud) 我有一张桌子,我希望获得一些价值checkbox并推入字符串.然后我正在尝试一个函数来获取值,但是它显示了对象Object,它不起作用.
<table id="div_table" border="2px" >
<tbody>
<tr>
<td><input type="checkbox" value="ABC" /></td>
<td>
<input type="checkbox" value="123" />
<input type="checkbox" value="456" />
<input type="checkbox" value="789" />
</td>
<td><input type="checkbox" value="xyz2" />
<input type="checkbox" value="xyz1" />
</td>
</tr>
</tbody>
</table>Run Code Online (Sandbox Code Playgroud)
我试过代码java函数
function getvalue_func()
{
$('#div_table > tbody > tr').each(function()
{
var str = '';
$(this).find('td').find("input:checked").each(function ()
{
for (var i = 0; i < $(this).length; i++)
{
str += $(this).val() + ',';
}
return alert(str);
});
});
}Run Code Online (Sandbox Code Playgroud)
示例:我选中了一些复选框:ABC,123,456和xyz2.结果:ABC,123,456,xyz2