开发者

href attribute of <a> not being set

开发者 https://www.devze.com 2023-04-07 00:51 出处:网络
In my application, I send an AJAX request to a server, and based on some data, I have to change the href attribute ofelement. Here\'s my code:

In my application, I send an AJAX request to a server, and based on some data, I have to change the href attribute of element. Here's my code:

$('#unclaimed_codes_list li').map(function(){
    $(this).children("a:first").text(fname + ' ' + lname + '(' + key + ')');
}

$.get('/accs/get_val/' + key, function(data){
    var edit_href = '/ak_access_levels/' + id + '/edit';
    alert(edit_href);
    $(this开发者_开发知识库).children("a:first").attr('href', 'edit_href');
});

But its not working. I can see that my edit_href value is correct, but still, the href attribute is not being set. Am I missing something? Thanks.


Replace the second occurence of $(this).children('a:first') by $('#unclaimed_codes_list li a:first'). Secondly, change 'edit_href' to edit_href.

0

精彩评论

暂无评论...
验证码 换一张
取 消