作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
for (var i in result)
{
$('#tgt').append( "<li><a href='/UpdateStatusData/?id='"+result[i]+" >"+result[i]+"</a></li>");
}
在服务器端提取时,我在 ID 中收到空白。请帮助我以有效的方式将值传递给标签。 but I am getting the value when i inspect the element along with ="" as extra, you can see it in the image value:MULTINOMIAL, but when I click I could only see blank value in the server side
最佳答案
截至目前,生成的链接将在下方,因此,id 将被忽略。
<a href'/UpdateStatusData/?id=' 123>
正确放置引号,以便将 url 括在引号中。
"<li><a href='/UpdateStatusData/?id="+result[i]+"'>"
//^Removes
//^added
使用更简洁的方法使用 jQuery 创建元素
var anchor = $('<a>', {
href : '/UpdateStatusData/?id='+result[i]
});
var li = $('<li>');
li.append(anchor);
$('#tgt').append(li);
关于javascript - 如何在 Jquery 中使用 href 标记和 URL 发送变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45055925/
我是一名优秀的程序员,十分优秀!