jquery - Apply function to specific elements -



jquery - Apply function to specific elements -

i know simple stuff, can't figure out...

how apply css changes multiple elements? @ moment, it's working first, showing no errors.

function eleminit(){ var elem1 = jq('#elem1'); var elem2 = jq('#elem2'); jq(elem1, elem2).each(function(){ jq(this).css({ 'margin-left': '-' + jq(this).width()/2 + 'px' }); }); }; eleminit();

jq ensure there's no conflict.

jquery selectors work css selectors, css method uses each method internally, can code:

jq('#elem1, #elem2').css('marginleft', function(i, oldmarginleft) { homecoming '-' + jq(this).width()/2 + 'px'; });

jquery

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -