Interviewer And Interviewee Guide

Web Development Ninjas Interview Question:

Tell me how do you retrieve attribute of an HTML tag using jQuery e.g. href of links?

Submitted by: Muhammad
The attr() method is used to retrieve the value of an attribute of any HTML element. You first need to select all links or specified links using the jQuery selector and then you can apply the attr() method to get the value of their href attribute. The code below will find all links from a page and return the href value :
view sourceprint?

$('a').each(function(){
alert($(this).attr('href'));
});
Submitted by: Muhammad

Read Online Web Development Ninjas Job Interview Questions And Answers
Copyright 2007-2024 by Interview Questions Answers .ORG All Rights Reserved.
https://InterviewQuestionsAnswers.ORG.