jquery - Javascript + HTML change html according to mobile size -


what i'm trying accomplish can't done media queries css.

<div class='bottom'>     <div class='left'>         <input type='submit' class='default' value='<?php echo order; ?>'/>     </div>     <div class='right'>         <input type='submit' class='default' value='<?php echo clear; ?>'/>         <input type='submit' class='default' value='<?php echo save; ?>'/>     </div> </div> 

this code works in screens > 533px - tablets, in smaller screens (mobile) 2 last buttons overlaps bottom.

i don't want ellipsis text first button, want create line of class 'bottom'. this:

<div class='bottom'>     <div class='right'>         <input type='submit' class='default' value='<?php echo clear;?>'/>         <input type='submit' class='default' value='<?php echo save;?>'/>     </div> </div> <div class='bottom'>     <div class='left'>         <input type='submit' class='default' value='<?php echo order; ?>'/>     </div> </div> 

as see i've php inside html, means can't remove whole divs , create in javascript (because won't php code).

the final solution duplicate class bottom, delete class left in original class bottom, , delete class right in duplicated class bottom.

if (window.matchmedia('(min-device-width: 533px)').matches) {     var class_bottom = $(".bottom").html(); // duplicated      $(".bottom .left").remove(); // works     $(class_bottom + " .right").remove(); // doesn't work     $(class_bottom).insertafter($(".bottom")); // doesn't work } 

thanks guys, solved.

if (window.matchmedia('(min-device-width: 533px)').matches) {     var class_bottom = $(".bottom").clone(); // nice trick      $(".bottom .left").remove();     $(class_bottom).find('.right').remove(); // remove right on clone     $(class_bottom).insertafter($(".bottom")); // insert after original class } 

you might need responsive layout using bootstrap 3. bootstrap 3 can solve above mentioned issue... the bootstrap library


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -