Tell me how do you retrieve attribute of an HTML tag using jQuery e.g. href of links?
Submitted by: MuhammadThe 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
view sourceprint?
$('a').each(function(){
alert($(this).attr('href'));
});
Submitted by: Muhammad
Read Online Web Development Ninjas Job Interview Questions And Answers
Top Web Development Ninjas Questions
☺ | Tell me how do you hide an image on a button click using jQuery? |
☺ | Do you know what elements have disappeared? |
☺ | Tell me how do you add and remove CSS classes to an element using jQuery? |
☺ | Suppose our hyperlink or image is not displaying correctly, what is wrong with it? |
☺ | Tell us how do you optimize a website’s assets? |
Top Web Developer Categories
☺ | Bootstrap Interview Questions. |
☺ | Front End Web Developer Interview Questions. |
☺ | Typography Interview Questions. |
☺ | Laravel PHP Developer Interview Questions. |
☺ | Junior Developer PHP Interview Questions. |