Why Cant add a class to an element by jquery In the page.tpl.php I have some elements like 

&lt;div class="play"&gt;&lt;/div&gt;


I have linked js file to the page and it is correctly works since all functions operate based on click attributes. but I would like to mudify some elements in page.tpl.php page. for example in my JS file I have a code like this:

$(".play").attr("id", "myID");


I could not make it working. basically it does not add myID to .play.

Any idea?
Going on little information provided its probably because you cannot access jQuery with the $ by default in drupal.  This is to prevent other library conflicts (see jQuery.noConflict())  If this is the case you will probably be getting an undefined function error in your console.  To fix this you can either use jQuery or wrap it in a function like this:

(function($){
  $(".play").attr("id", "myID");
})(jQuery);


or can do this:

jQuery(".play").attr("id", "myID");


By default the version of jQuery that is used on drupal is 1.5.  You may consider using jQuery Update module for a newer version.

"Many JavaScript libraries use $ as a function or variable name, just as jQuery does. In jQuery's case, $ is just an alias for jQuery, so all functionality is available without using $. If you need to use another JavaScript library alongside jQuery, return control of $ back to the other library with a call to $.noConflict(). Old references of $ are saved during jQuery initialization; noConflict() simply restores them."