freeCodeCamp/guide/portuguese/certifications/front-end-libraries/jquery/target-the-parent-of-an-ele.../index.md

388 B

title localeTitle
Target the Parent of an Element Using jQuery Segmentar o pai de um elemento usando jQuery

Segmentar o pai de um elemento usando jQuery

Solução

<script> 
  $(document).ready(function() { 
    $("#target1").parent().css("background-color", "red"); // Selects the parent of #target1 and changes its background-color to red 
  }); 
 </script>