PrepAway - Latest Free Exam Questions & Answers

Which jQuery code segment or segments should you use?

DRAG DROP
You are developing a website that has many web pages with hyperlinks to other sites.
You need to ensure that if a hyperlink contains an image, the linked web page opens in a new window.
Which jQuery code segment or segments should you use? (To answer, drag the appropriate line of code to the
correct location. Each line of code may be used once, more than once, or not at all. You may need to drag the
split bar between panes or scroll to view content.)
Select and Place:

PrepAway - Latest Free Exam Questions & Answers

Answer:

Explanation:
* a img
All elements that are descendants of an element.* (this).parent
This is the element and is the parent.

3 Comments on “Which jQuery code segment or segments should you use?

  1. lolloo says:

    The answer is wrong. With the selector $(‘a’) every Hyperlink become the target Attribute. But the requirement is:

    You need to ensure that if a hyperlink CONTAINS an image, the linked web page opens in a new window.

    So the selector must be: $(‘a img’) and then in the second $(this).parent




    1



    1

Leave a Reply