How to find all the anchor tags inside a div tag and need to append one more property to the anchor tag. say target="_blank".
How can i do this in using jquery?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Do you mean all the anchors in any div element, or in some specific div element? If it’s the former, this will do the trick:
If it’s a particular div you’re interested in, give that element an id attribute and then use it like so:
replacing “divid” with the id in question.
Can you be more specific about what exactly you want?
In any case, you’re going to need to use the
attr()function to set the attribute; see the documentation here.