$(document).ready(function () { $("#entireDiv").click(function () { $(".targetDiv").css({ 'color': 'red', 'background-color': 'orange' }); }); $("#children").click(function () { $(".targetDiv").children().css({ 'color': 'red', 'background-color': 'orange' }); }); $("#reset").click(function () { location.reload(); }); });
<html> <head> <title>children</title> </head> <body> <div class="targetDiv">This is <em>99codingexamples</em></div> <div class="targetDiv">I love <b>jQuery</b></div><br /><br /> <input type="button" id="entireDiv" value="Entire Div" /> <input type="button" id="children" value="children()"/> <input type="button" id="reset" value="Reset" /> </body> </html>