href attribute of <a> not being set
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
.
精彩评论