javascript - Replacing in-line div style -



javascript - Replacing in-line div style -

i'm trying replace in-line styling of div using dojo. want alter min-height property, without affecting other in-line properties.

here current html:

<div id="divid" class="divclass" style="width: 950px; min-height: 225px;">

here script string:

dojo.query('div.divclass').css( "min-height", "0px" );

but seems have no effect @ all. if seek swap .css() .attr() works fine except removes other styling - .attr('style', 'min-height:0px'); manually editing div code not alternative i'm looking workaround. tried appending class in-line styling overwrites it.

i got .css() part jquery site maybe it's not compatible dojo? sorry i'm pretty new this.

thanks

there alternative dojo (compared jquery), however, function called style() in stead of css(), example:

dojo.query('div.divclass').style( "min-height", "0px" );

also, functionality not available default, need load module dojo/nodelist-dom, because contains dom functionalities nodelist (which list of nodes when utilize dojo/query module).

another little thing notice: sure dom loaded before you're going query it, if dom isn't loaded yet, there's nil query either.

a total illustration (using amd) be:

require([ "dojo/query", "dojo/nodelist-dom", "dojo/domready!" ], function(query) { query('div.divclass').style( "min-height", "0px" ); });

the dojo/domready! module similar $(document).ready() in jquery, makes sure dom loaded before query it.

the working illustration can found on jsfiddle: http://jsfiddle.net/eu9br/

javascript jquery dojo

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -