Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9029369
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T07:14:07+00:00 2026-06-16T07:14:07+00:00

I have a <div> like below <div class=divClass> <ul class=ulClass> <li id=liID class=liClass> <a

  • 0

I have a <div> like below

<div class="divClass">
<ul class="ulClass">
    <li id="liID" class="liClass">
        <a href="myLink">
        <span class="spanClass">myText</span>
        </a>
    </li>
</ul>
</div>

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

$('.divClass').click(function(e){

$(this).find('.aclass').text("yeeee");
$(this).find('.imgclass').attr("src", "remove_favorit.png");

e.preventDefault(); 

});

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 Get attribute of child element

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T07:14:09+00:00Added an answer on June 16, 2026 at 7:14 am

    I think you don’t want it to happen on click but following code will set the target=_blank on clicking on a link inside divClass

    $(function(){
        $('.divClass .ulClass .liClass').on('click', 'a', function(e){
            $(this).attr('target', '_blank');
            e.preventDefault();
        });
    });​
    

    And this code will do it on page load

    $(function(){
        $('.divClass .ulClass liClass a').attr('target', '_blank');
    });​
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have many controls like below : <div style=display: inline;> <span id=cvCaptcha-Target class=ttTarget> <asp:CustomValidator
I have a HTML document like below: <td> <div class="commentLink"> <a href="javascript:ShowBox()">Show</a> </div> <div
I have 4 divs with content like below: <div class=prodNav-Info-Panel>content</div> <div class=prodNav-Usage-Panel>content</div> <div class=prodNav-Guarantee-Panel>content</div>
I have html structure like below: <div id=banner-menu-holder> <div> <div class=avalible> <div class=items-holder> <div>
Scenerio: I have some divs populated through foreach loop like below <div id=div1><input type=hidden
I have a div like this... <div class=user> <div class=info> ..... </div> <div class=edit>
I have a div like this: <div id=popupDiv1 class=popupDivClass> <a id=popupDivClose class=popupCloseClass>x</a> </div> When
I have a div like this <section class=item_container> <article class=item> <h2>Page Title</h2> <p><a class=delete_page
I have an image div like this <div class=bgCover>&nbsp;</div> <div class=overlayBox style=position: fixed; background-image:
I have 1 div that will contain 3-5 divs with the same class. Below

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.