2017-03-14 3 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>