I’m trying to modify anchor tag href ausing jQuery as per below, but I couldn’t persist the changes I made into htmlFragment below.
It seems like jQuery selector copies the value, rather than uses the reference?
Can I save the modified href value without copying into a new element ?
<div class="photo"><a class="photo_large" href=http://myimage/a/1.jpg>AAAA</a></div>
<div class="photo"><a class="photo_large" href=http://myimage/b/1.jpg>AAAA</a></div>
function(err, htmlFragment) {
var photosImg = $('.photo_large', htmlFragment);
$(photosImg[0]).attr('href', '');
$(photosImg[1]).attr('href', '');
$(photosImg[2]).attr('href', '');
$('#mydivout').html( htmlFragment );
}
Turned out that I have to wrap normal DOM elem into JQuery
Otherwise jQuery won’t save any modified data back into DOM.
I can’t reproduce what I got in jsFiddle for unknown reason, i got it working on my system.