Change/Add the child of child's element <a>'s target attribute via Jquery

J0ker

New Member
I have a div like below \[code\]<div class="divClass"><ul class="ulClass"> <li id="liID" class="liClass"> <a href="http://stackoverflow.com/questions/14034970/myLink"> <span class="spanClass">myText</span> </a> </li></ul></div>\[/code\]Now I want to write a Jquery script to read the "a" element and set the value of target attribute to "_blank". I went through JQuery change atributes of child elements and got a script. But, it gave me a script like below\[code\]$('.divClass').click(function(e){$(this).find('.aclass').text("yeeee");$(this).find('.imgclass').attr("src", "remove_favorit.png");e.preventDefault(); });\[/code\]What I actually want is iterate through div, ul, li and then reach out to the "a" in it and set the target. How can I do this?I also went through jquery: get attribute of child element
 
Back
Top