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
Post a Comment