0

What is the selector I need in order to find the class "imgBtn" inside the link that I clicked (class - "checkVacancy a")?

      <div class="checkVacancy">
    <a rel="123">
        <img class="imgBtn" alt="" src="App_Themes/popup/bilder/btn_pruefen.png">
    </a>
    <div class="32531302a"></div>
  </div>
  <div class="checkVacancy">
    <a rel="123">
        <img class="imgBtn" alt="" src="App_Themes/popup/bilder/btn_pruefen.png">
    </a>
    <div class="32531302b"></div>
  </div>
  <div class="checkVacancy">
    <a rel="123">
        <img class="imgBtn" alt="" src="App_Themes/popup/bilder/btn_pruefen.png">
    </a>
    <div class="32531302c"></div>
  </div>

This is the JS I use

   $(function(){
        $('.checkVacancy a').click(function() {

          //access only child image
          $('.imgBtn').attr('src','http://www.ajaxload.info/cache/9D/E5/1C/00/00/00/1-0.gif');                  

        });
    });

example jsbin

4 Answers 4

4

What you want is

var imgBtn = $(this).find('.imgBtn');

This will find the image within the link that you clicked.

Sign up to request clarification or add additional context in comments.

Comments

1

Use this function:

$(".checkVacancy a").click(function() {
   var theImage = $(this).find(".imgBtn"); 
});

Comments

0

This will get you all imgBtn within a within checkVacancy divs:

$('div.checkVacancy a .imgBtn')

Comments

0

If I understand your problem correctly, I think you need to add "this" to your .imgBtn selector, like this:

$('.imgBtn', this).attr('src','http://www.ajaxload.info/cache/9D/E5/1C/00/00/00/1-0.gif');

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.