javascript - is there a way to run the jquery.live function without any event -


the live function of jquery triggered event api documentation here
http://api.jquery.com/live/

$(".xyz").live('event', function(){     }); 

i want above function run without event , i.e class xyz dynamically created.

i have tried without event parameter

$(".xyz").live( function(){     }); 

but doesn't work !!

adding

i don't know want do, i'll make assumptions.

scenario 1

in order execute function inside jquery, need tell jquery when execute function, otherwise cannot know. 1 way is:

$(document).ready(function () {     $('.xyz').css('color', 'red');     // more code, anything, functions, calculations, etc. }); 

the code inside function executed dom ready (is safe manipulate). can put $('.xyz').css('color', 'red'); outside ready() event , executed. "event" time when executions of page reaches line of code. example, if put line before html, don't have guarantee work.

scenario 2 - onclasschange event

if looking event called onclasschange, not exits on jquery. approach problem this:

  • create timer runs infinitely
  • on each run, check if object has class ( $(obj).hasclass('xyz') )
  • if yes, whatever want inside if ()

also, since said class xyz created dynamically, can try run function after create class in code.

for more onclasschange event, there long discussions can check on site.


Comments

Popular posts from this blog

jsf - "PropertyNotWritableException: Illegal Syntax for Set Operation" error when setting value in bean -

arrays - Algorithm to find ideal starting spot in a circle -

php - Autoloader issue not returning Class -