jquery - Setting element width() does not work with a variable -


i'm trying set element width using jquery , won't work.

here code:

var $padding = 30, $oddwidth = parseint( math.round( $(window).width()*0.75 ) ), $odd = $oddwidth-$padding;  $('div:jqmdata(role="content")').css({ 'margin-left':'25%'}).width( $odd ); 

can me out?

the following working me, wrapping jquery code inside following?

$(document).ready(function() {     $("div:jqmdata(role='page')").live('pageshow',function(){         var $padding = 30,         $oddwidth = parseint( math.round( $(window).width()*0.75 ) ),         $odd = $oddwidth-$padding;         $('div:jqmdata(role="content")').css({ 'margin-left':'25%'}).width( $odd );     }); }); 

jquery.mobile has different document.ready() when "page" loaded, perhaps without this, width() not correct or <div data-role="content"> not exist yet.


Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -