Getting value from key pair value into appended property using jQuery
- by Neil
How do I get the value from a key pair value into the rel property of an anchor tag?
When I split the code to put the value in the correct place it doesn't work, the end of the a tag would appear on screen instead value wouldn't be applied. When I look at the resulting code in console in Firebug the rel and href swapped order so the rel is first.
The 'key' should be and is in the correct location but the 'value' needs to be applied to the rel attribute.
What am I doing wrong?
$(function() {
var obj = {"firstThing":"4","secondThing":"6","aThirdThing":"2","anotherThing":"3","followedByAnother":"4"};
$.each(obj, function(key,value) {
$('#newmine').append("<li class='tagBlocks'>","<a href='#' rel=''>",value," ",key);
});
});