小编Daw*_*ven的帖子

根据屏幕大小折叠div元素

我只是想知道,根据屏幕尺寸,你可以使用bootstraps 手风琴,所以举个例如我说我有一个div我想要定期显示所有东西,但在移动视图中我希望它崩溃.

有什么建议?

html javascript css twitter-bootstrap

5
推荐指数
2
解决办法
2万
查看次数

Jvectormap突出显示多个国家/地区

我目前正在使用JvectorMap并试图突出显示多个国家/地区,当我将鼠标悬停在文本上时,我已经明白了如果我将鼠标悬停在非洲这个词上,它会突出显示整个地图,我将如何过滤它以突出非洲当我我徘徊在非洲的内容名称上.

目前我正在创建一个使用a jQuery.each和我返回的大陆列表continentCodes,其中包含分配给它们的所有国家代码(ZA,US)...我尝试过以下操作:

jQuery('.continentLink').hover(function() {
 jQuery.each(mapObject.mapData.paths, function(i, val) {
  if (val.continent == "africa"){
   continentCodes[i] = "#3e9d01";
   mapObject.series.regions[0].setValues(continentCodes);
  }
 });
});
Run Code Online (Sandbox Code Playgroud)

但后来我重复了每一个声明,我无法获得动态的大陆.

这是一个JSFIDDLE

所以继承人JS:

jQuery(function(){
//JSON MARKERS
var markers = [{latLng: [-34.033333300000000000, 23.066666700000040000], name: 'Knysna', info:'its got a lake...'},
    {latLng: [-33.924868500000000000, 18.424055299999963000], name: 'Cape Town', info:'its nice...'}];
//JSON MARKERS  

//JSON STYLING
var markerStyle = {initial: {fill: '#F8E23B',stroke: '#383f47'}};
var regionStyling = {initial: {fill: '#128da7'},hover: {fill: "#A0D1DC"}};
//JSON STYLING

//GLOBAL VARIABLES
var countryList = "", continentList …
Run Code Online (Sandbox Code Playgroud)

javascript each jquery jvectormap

5
推荐指数
0
解决办法
5272
查看次数

Javascript Human Readable Filesize

我目前正在尝试将此php函数转换为javascript:

function human_filesize($bytes, $decimals = 2) {
  $sz = 'BKMGTP';
  $factor = floor((strlen($bytes) - 1) / 3);
  return sprintf("%.{$decimals}f", $bytes / pow(1024, $factor)) . @$sz[$factor];
}
Run Code Online (Sandbox Code Playgroud)

这就是我的目标:

function human_filesiz(bytes){
            var decimals = 2;
            var sz = 'BKMGTP';
            var factor = Math.floor((bytes.length - 1) / 3);
            return (bytes / Math.pow(1024, factor));
            //return sprintf("%.{$decimals}f", $bytes / pow(1024, $factor)) . @$sz[$factor];
        }
Run Code Online (Sandbox Code Playgroud)

我只是在最后一行挣扎.任何帮助都非常赞赏.

javascript php

3
推荐指数
2
解决办法
1301
查看次数

jQuery Google Maps按ID获取标记

我目前有以下代码:

jQuery.each(json,function(index,value){
            var id =json[index]["id"];
            var location =json[index]["location"];
            var tel =json[index]["tel"];
            var lat=json[index]["lat"];
            var lng=json[index]["lng"];

            marker = new google.maps.Marker({
              id:id,
              position: new google.maps.LatLng (lat, lng),
              icon: {
                    path: google.maps.SymbolPath.CIRCLE,
                    fillOpacity: 1,
                    fillColor: '#002664',
                    strokeWeight: 1, 
                    strokeColor: '#FFFFFF',
                    scale: 5 //pixels
                },
              map: map
            });

            google.maps.event.addListener(marker, 'click', function() {
                jQuery('.office-information').slideUp(300);
                if(!jQuery('#office-info-'+id).is(':visible')){
                    jQuery('#office-info-'+id).slideDown(300);
                }
            });

            google.maps.event.addListener(marker, 'click', function() {
            });

            jQuery('.get-direction').on('click', function(){
                var markerID = this.id.replace( /[^\d.]/g,'');
                console.log(marker);
            });

      });
Run Code Online (Sandbox Code Playgroud)

问题领域是:

jQuery('.get-direction').on('click', function(){
                    var markerID = this.id.replace( /[^\d.]/g,'');
                    console.log(marker);
                });
Run Code Online (Sandbox Code Playgroud)

基本上,当我点击一个带有类的链接时,get-direction …

javascript jquery google-maps-api-3

2
推荐指数
1
解决办法
1万
查看次数

jQuery - 在键盘上转到下一个输入字段

我现在忙于13个输入字段,结果被合并到变量中,我必须将其拆分为13,因为我需要添加块效果,例如您将在现实世界中的许多表单上找到它.每个块的限制是一个,我需要找到,所以当你插入一个数字,它会进入下一个字段,直到所有字段都已填充,然后验证功能将启动.

继承人html:

<div id="error"></div>

<form id="idCheck">
<input class="id" id="idnumber1" maxlength="1" />
<input class="id" id="idnumber2" maxlength="1"  />
<input class="id" id="idnumber3" maxlength="1"  />
<input class="id" id="idnumber4" maxlength="1"  />
<input class="id" id="idnumber5" maxlength="1"  />
<input class="id" id="idnumber6" maxlength="1"  />
<input class="id" id="idnumber7" maxlength="1"  />
<input class="id" id="idnumber8" maxlength="1"  />
<input class="id" id="idnumber9" maxlength="1"  />
<input class="id" id="idnumber10" maxlength="1"  />
<input class="id" id="idnumber11" maxlength="1"  />
<input class="id" id="idnumber12"  maxlength="1" />
<input class="id" id="idnumber13" maxlength="1"  /><span id="status"></span>
<p> <input type="submit" id="check" value="Check" /> </p>
 </form> …
Run Code Online (Sandbox Code Playgroud)

javascript jquery

1
推荐指数
1
解决办法
4670
查看次数

jQuery - 如果这个或这个失败输入名称

我试图得到输入的名称,这个微小的验证失败了,如下所示:

 var username = jQuery("#modlgn-username").val();
 var password = jQuery("#modlgn-passwd").val();

  if(username < 2 || password < 2){
   jQuery('.login-error').html('Incorrect'+jQuery(this).attr("name")).slideDown(300);
  }else{
   sendLogin(datasubmit);
  }
Run Code Online (Sandbox Code Playgroud)

但到目前为止,我一直很不成功.这是可能吗?

更新:

对不起,我的问题似乎不清楚,我知道如何验证部分罚款的字段..我正在努力:

jQuery(this).attr("name");
Run Code Online (Sandbox Code Playgroud)

它不会返回失败的输入名称.我如何获得失败的输入名称?

javascript jquery

0
推荐指数
1
解决办法
72
查看次数

jQuery如果value为空,则将其设置为0并进行验证

简单问题我无法解决,我有以下功能:

function finalCheck(){

        var result = true;
        jQuery("#carloan-form :input[type=text]").each(function() {

            if(!this.value){this.value = 0;}

            if(jQuery.isNumeric(this.value) && this.value>=0) {
                jQuery(this).parent().children('.cal-error').slideUp(300)
            }else{
                result = false;
                jQuery(this).parent().children('.cal-error').slideDown(300);
                jQuery('.cal-result').slideUp(300);
            }
        });
        return result;
    }
Run Code Online (Sandbox Code Playgroud)

基本上问题是if(!this.value){this.value = 0;}如果没有值我需要在继续验证表单之前将其设置为零,但这似乎只在我第二次验证时生效.

所以这一切归结为如果我在每个循环中将输入值设置为0,它只在函数完成后将其考虑在内.

这是一个JSFIDDLE,与我当前的问题相同,只有在第二次单击时才会显示正确的值.

任何帮助都非常赞赏.

javascript validation jquery

0
推荐指数
1
解决办法
1万
查看次数