- 2
Select all<a> links in which inside of the para tags
ans
6 Answers
+ 3
Without JQuery:
var p=document.getElementById('myP'); // or anyelse ref' to an html element...
var links=p.querySelectorAll('a'); // return an array of links elements inside 'p' element.
or:
var links=document.querySelectorAll('#myP a');
And with JQuery, you can do at least the same and solution of @florin holban... which may be corrected a few:
var links=$('p a'); /* OR $('p > a') */
As in querySelectorAll(), the string argument required is a valid css selector, so difference between setting the greater than sign ( > ) or not is to select only direct childs or all childs and grand childs respectively ^^
+ 2
@florin holban:
What require correction in your answer is the parenthesis content: you write "$('p' 'a') or $('p' > 'a')" instead of "$('p a') or $('p > a')" ( too much quotes ;) )
0
Maake a class.a-in-p and $('a-in-p') selects them. Or $('p' 'a') or $("p" > "a") for first class a tags of p tags
0
True! My answer could be corrected! One does need to put this in a var and assign a query selector!
0
:) true! :) i'm seeing it now! :)
- 1
$ ("p a")