Select anchor link inside p span - Javascript jQuery Method and Property

Javascript examples for jQuery Method and Property:has

Description

Select anchor link inside p span

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
    $("p span").has("a[href]").css("background-color", "yellow");
});/* w  w  w . ja v a2 s  .  c om*/
</script>
</head>
<body>

<p>My <span>name</span> is tutorial. <span><a href="http://java2s.com">java2s.com</a></span></p>
<p>this is from <span><a href="http://java2s.com">java2s.com</a></span>. Come visit me!</p>
<p>My <span>best</span> friend is span.


</p>

</body>
</html>

Related Tutorials