Tutorial #5 del Curso de Jquery, en este tutorial seguimos viendo selectores y como estos nos ayudan a seleccionar elementos del DOM.
<!DOCTYPE html> <html lang="es"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>selectores 2</title> </head> <body> <p class="texto">hola</p> <p class="der">hola</p> <p class="texto">hola</p> <script src="js/jquery-2.1.3.min.js"></script> <script type="text/javascript"> $(document).ready(function() { $('.texto').css('color','red'); }); </script> </body> </html>
<!DOCTYPE html> <html lang="es"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>selectores 3</title> </head> <body> <p title="hola">un texto</p> <p title="texto">un texto</p> <p>otro parrafo</p> <script src="js/jquery-2.1.3.min.js"></script> <script type="text/javascript"> $(document).ready(function() { $('p[title=hola]').css('color','red'); }); </script> </body> </html>
<!DOCTYPE html> <html lang="es"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>selectores 4</title> </head> <body> <p>un texto</p> <p>otro texto</p> <script src="js/jquery-2.1.3.min.js"></script> <script type="text/javascript"> $(document).ready(function() { $('p').css('color','red'); }); </script> </body> </html>