javascript - jQuery: Executing code for each element that matches a selector -


$ ("p") references all paragraphs on the current web page Is it possible to execute the code for each matching element?

This is a simple example in pseudo-code:

  // Show the background color of each paragraph page front (object = $ ("p")) {alert .css ("background-color")); }  

  $ ('p'). CSS ('background color if you need more flexibility:  
  $ (' p '). Each (function () {$ (this) .css (' background-color ',' Red ');});  

Comments