里面的jquery函数html href代码不能正常工作(Inside jquery function html href code not working properly)

编程入门 行业动态 更新时间:2024-10-28 00:24:59
里面的jquery函数html href代码不能正常工作(Inside jquery function html href code not working properly)

问题就在于此

$('<td></td>').val(item['id']).html( '<a href="edit.html?id'='+sid'">Edit</a>'),alert(sid+"Id2:"+item['id']),

这里的警报很清楚..但是在浏览器中显示路径

//localhost:8080/sample/teacher/edit.html?id'=sid”

这里没有显示sid的值,即id 41我希望将链接显示为

localhost:8080 / sample / teacher / edit.html?id = 41或任何其他动态id值

我不知道为什么这会发生代码不对

这里var sid是一个数组和推送值id到数组..警报正确显示sid&item ['id']的值。

$.each(responseData, function(index, item) { var sid = []; $('#student').append( $('<td></td>').val(item['id']).html( item['name']), $('<td></td>').val(item['id']).html( item['phoneNo']), sid.push(item['id']), $('&t;td></td>').val(item['id']).html( '<a href="edit.html?id'='+sid'">Edit</a>'),alert(sid+"Id2:"+item['id']), $('<td></td>').val(item['id']).html( '<button onclick="lightbox1_open();">Delete</button>'), $('<br />').val(item['id']).html( item[''])); });

如果你知道答案,请在这里分享......

the problem was in the line

$('<td></td>').val(item['id']).html( '<a href="edit.html?id'='+sid'">Edit</a>'),alert(sid+"Id2:"+item['id']),

here the alert is getting clearly.. but in browser the path shows

//localhost:8080/sample/teacher/edit.html?id'=sid'

here not shows the value of sid that is id 41 i want to show the link as

localhost:8080/sample/teacher/edit.html?id=41 or any other dynamic id value

i don't know why this happen the code is not right

Here var sid is an array & push value id to array.. the alert shows the value of sid & item['id'] correctly.

$.each(responseData, function(index, item) { var sid = []; $('#student').append( $('<td></td>').val(item['id']).html( item['name']), $('<td></td>').val(item['id']).html( item['phoneNo']), sid.push(item['id']), $('<td></td>').val(item['id']).html( '<a href="edit.html?id'='+sid'">Edit</a>'),alert(sid+"Id2:"+item['id']), $('<td></td>').val(item['id']).html( '<button onclick="lightbox1_open();">Delete</button>'), $('<br />').val(item['id']).html( item[''])); });

if you know the answer please share here...

最满意答案

看起来字符串连接是问题,试试

$('<td></td>').val(item['id']).html('<a href="edit.html?id=' + sid + '">Edit</a>')

Looks like the string concatenation is the problem, try

$('<td></td>').val(item['id']).html('<a href="edit.html?id=' + sid + '">Edit</a>')

更多推荐

item,sid,'id',html,电脑培训,计算机培训,IT培训"/> <meta name="

本文发布于:2023-07-29 05:06:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1312608.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:不能正常   函数   代码   工作   html

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!