How to find an element or tag using Jquery

The HTML is here:

<table class="table">
 <caption>My testing Table</caption>
  <tr>
    <td class=""><span>data-1</span></td>
    <td>data-2</td>
  </tr>
  <tr>
    <td>data-3</td>
    <td><span>data-4</span></td>
  </tr>
</table>

The Script is:

// ONLINE JQUERY LIBRARY IS CONNECTED
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
<script>
$(document).ready(function()
{
 
   // FINDS SPAN TAG IN CLASS TABLE AND CHANGE ITS CSS STYLE
 $(".table").find("span").css({"color":"blue","background":"lightpink"});
});
</script>

For any reference visit: http://www.w3schools.com/jquery/traversing_find.asp

Leave a Comment