I am trying to set the CSS style with .live (). CSS function:
$(".data tr:odd").addClass("evenrows");
Is there a way for this to happen automatically when preparing a document, but still for future elements? I have an ajax event on a page that reorders a table. I need these newly created lines to apply their .addClass.
Thanks in advance.
you can use the livequery plugin . It binds to DOM mutation events to track changes in the DOM, and re binds and re executes the code attached to them, for example:
$(".data tr:odd").livequery(function(){ $(this).addClass("evenrows"); });
, Ajax , . . "" : http://docs.jquery.com/Ajax/jQuery.ajax#options
Live . .: http://docs.jquery.com/Events/live#typefn
JavaScript ajax, . , , , .
:
GlobalObject.AjaxFunction(sUrl, SData, fnOnSuccess, fnOnError, oExtension) { //Set up Ajax process // check type of extension as a function if (typeof oExtension === 'function') { oExtension(); } }
ajax.
, , , !