2017-03-14 8 views
1

jqueryスクリプトを少し参考にしてください。私はjqueryスクリプトを少し使って何かを達成しようとしています(それは素晴らしいです)が、これはデスクトップ専用の仕事に必要です。タブレットや携帯電話では無効にする必要があります。デスクトップ専用のjqueryスクリプト

私が使用しているスクリプトが

jQuery(document).ready(function($) { 
    var max = 0; 
    $(".sameheight .x-column").each(function(index, el) { 
    if($(this).height() > max){ 
     max = $(this).height(); 
    } 
    }); 
    $(".sameheight .x-column").css('height', max); 
}); 

誰かが私を助けてくださいことはできますか?ありますか

あなたは

+0

可能重複[自動(ユーザエージェントを介して?)モバイルブラウザを検出](http://stackoverflow.com/questions/1005153/auto-detect-mobile-browser-via -ユーザーエージェント) –

答えて

0

あなたが1024pxを超えるように、本体幅をチェックしてからコードを実行することができますありがとうございました。

以下の例。

var width = $("body").width(); 
 
console.log(width); 
 

 
if (width > 1024) { 
 
alert("Over 1024;") 
 
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
 
<body> 
 

 
</body>

0

私が正しくあなたを理解していればplsはこの

NBを試してみてください: - Plsはフルスクリーンモードでのスニペットをしてみてください。

function resizeColumnOnDesktop() { 
 
    var width = $("body").width(); 
 
    if (width > 1024) { 
 
    var max = 0; 
 
    $(".sameheight .x-column").each(function(index, el) { 
 
     if ($(this).height() > max) { 
 
     max = $(this).height(); 
 
     } 
 
    }); 
 
    $(".sameheight .x-column").css('height', max); 
 
    } 
 
}; 
 
$(window).on("load resize", function(e) { 
 
    resizeColumnOnDesktop() 
 
});
.x-column { 
 
    background: #EEE; 
 
    width: 20%; 
 
    float: left; 
 
    margin: 5%; 
 
    padding :10px; 
 
    text-align: justify; 
 
    border:1px solid #000; 
 
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
 
<div class="sameheight"> 
 
    <div class="x-column">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It 
 
    has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop 
 
    publishing software like Aldus PageMaker including versions of Lorem Ipsum.</div> 
 
    <div class="x-column">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It 
 
    has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop 
 
    publishing software like Aldus PageMaker including versions of Lorem Ipsum.Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer 
 
    took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset 
 
    sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</div> 
 
    <div class="x-column">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to </div> 
 
    <div class="x-column">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It 
 
    has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop 
 
    publishing software like Aldus PageMaker including versions of Lorem Ipsum.</div> 
 
    <div class="x-column">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It 
 
    has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop 
 
    publishing software like Aldus PageMaker including versions of Lorem Ipsum.Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer 
 
    took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset 
 
    sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's 
 
    standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. 
 
    It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</div><div class="x-column">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text </div> 
 
</div>

関連する問題