小编Dan*_*ilo的帖子

如何检查JavaScript中的字符串是否全部大写?

有一个Javascript/Jquery布尔函数来测试字符串是否全部大写?

匹配的例子:

"hello" => false
"Hello" => false
"HELLO" => true
Run Code Online (Sandbox Code Playgroud)

javascript string

30
推荐指数
3
解决办法
4万
查看次数

Jquery自动获取div中所有元素的值

我有一个主div,里面有很多输入文字和单选按钮.像这样:

<div id="mainDiv">
   <input type="text" name="text-1" /> <br/>

   <input type="radio" name="radio-1" />Yes
   <input type="radio" name="radio-1" />No <br/>

   <input type="text" name="text-2" /> <br/>
   <input type="text" name="text-3" /> <br/>
</div>
<img src="img/img.gif" onclick="getAllValues();" />
Run Code Online (Sandbox Code Playgroud)

我想在JQuery中定义函数"getAllValues()",它获取"mainDiv"中的所有值并将它们保存在字符串中.有可能的?

html javascript forms jquery

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

按类调用CKEditor

我需要自动调用CKEditor的多个实例...实际上我使用的函数:

CKEDITOR.replace( 'editor1');
Run Code Online (Sandbox Code Playgroud)

其中"editor1"是我想要显示我的CKEditor的div的id名称.

我正在使用jQuery来自动化这个过程,我需要使用"class"标签而不是id.

特别是我有这个HTML:

<div class="CKEditor">
    <div class="text">
            mytext
    </div>

    <p style="text-align:center" class="buttons">
        <input type="button" value="edit" class="button_edit">
        <input type="button" value="preview" class="button_preview" style="display:none">
    </p>

    <div class="editor" >
    </div>

</div>
Run Code Online (Sandbox Code Playgroud)

和这个jQuery脚本:

$(function() 
{
    $('.CKEditor').each(function()
    {
        var __main = $(this);
        var __buttons = __main.children('.buttons');
        var __text = __main.children(".text");
        var editor;

        __buttons.children('.button_edit').click(function()
        { 
            __text.hide();
            if (editor) return;

            editor = CKEDITOR.replace("editor");
            editor.setData(__text.html());

            if(editor)
            { 
                __buttons.children('.button_edit').hide(); 
                __buttons.children('.button_preview').show(); 
            }
        });

        __buttons.children('.button_preview').click(function()
        {
            __text.show();
            __text.html(editor.getData());

            if ( !editor ) return;

            editor.destroy();
            editor = null;
            __buttons.children('.button_edit').show(); 
            __buttons.children('.button_preview').hide(); …
Run Code Online (Sandbox Code Playgroud)

javascript jquery ckeditor

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

带有数值的$在Delphi中意味着什么

在Delphi中,当我看到这样的命令时,这意味着什么:

char($23)
Run Code Online (Sandbox Code Playgroud)

在这种背景下,美元符号意味着什么?

delphi string char

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

Java从int var获取第一个和最后一个2字节

我想将一个int转换为2个字节,表示该int.

可能必须使用按位和位移,但我不知道该怎么做.

int x; /* val to convert */


// ?????????


int b12; /* the first 2 bytes */
int b34; /* the last  2 bytes */
Run Code Online (Sandbox Code Playgroud)

java bit-manipulation bit-shift

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

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

PHP:创建一个裁剪的矩形缩略图

我正在尝试调整大小并裁剪@imagecopyresampled原始宽高比的图像.

这个想法是:1)我修复了缩略图的尺寸(fe 300x40)2)裁剪开始到高度的中心

在此输入图像描述 在此输入图像描述

我试图在stackoverflow上阅读文档和许多其他问题,但没有结果.谁能帮帮我?我的实际代码如下:

//$img_height, $img_width [original size of the image]

$thumb_width  = 300;
$thumb_height = 40;
$new_img = @imagecreatetruecolor($thumb_width, $thumb_height);
$middle = floor($img_height/2);

$src_x = 0;
$src_y = $middle-($thumb_width/2);

$src_w = $img_width;
$aspectRatio = $img_width/$thumb_width;

//$src_h = ?????

$imgCopyRes = @imagecopyresampled(
                  $new_img, $src_img,
                  0, 0, 
                  $src_x, $src_y, 
                  $thumb_width, $thumb_height, 
                  $src_w, $src_h);
Run Code Online (Sandbox Code Playgroud)

编辑:

非常感谢@Joshua Burns,阅读你的课程并编辑你的代码我找到了解决方案而不包括整个文件.

码:

$target_width  = 300;
$target_height = 40;
$new_img = @imagecreatetruecolor($target_width, $target_height);

$width_ratio  = $target_width  / $img_width;
$height_ratio = $target_height / $img_height;
if($width_ratio > …
Run Code Online (Sandbox Code Playgroud)

php image crop

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

JavaFX标签高度

我正在使用JavaFX和JavaFX Scene Builder开发软件.

我有一个有2列的网格窗格.实际上在每个单元格中都有标签.在表的第一列中,标签内的文本是默认常量,在第二列中文本可以更改.

问题是如果文本变量太长,它会自动截断.

如何开始修剪文本的新行并重新调整网格窗格中行的高度?

编辑:

感谢@fabian问题,这是初始问题的解决方案.在成瘾中有必要将每个元素的fx:id设置为Scene Builder.

@FXML private GridPane gridPane;
@FXML private Text text1;
@FXML private Text text2;
@FXML private Text text3;


private void setGridRowHeight(GridPane gpName, int numRow, double height){
    ObservableList<RowConstraints>  rows = gpName.getRowConstraints();
    rows.get(numRow).setMinHeight(32);
    rows.get(numRow).setPrefHeight(height);
    rows.get(numRow).setMaxHeight(height);
}


private void addTextListener(final GridPane gridPane, final Text text){

    text.textProperty().addListener(new ChangeListener<String>() {
        @Override
        public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
            scrollPane.setFitToHeight(true);
            text.setWrappingWidth( gridPane.getColumnConstraints().get(1).getPrefWidth() );
            setGridRowHeight(gridPane, gridPane.getRowIndex(text), text.getLayoutBounds().getHeight() );
        }
    });
}


@FXML public void initialize() { …
Run Code Online (Sandbox Code Playgroud)

java height label javafx scenebuilder

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

Jquery将元素从div移动到另一个

我有两个列表:第一个显示在左侧,第二个显示在右侧.我希望如果我单击左侧的元素,他将被删除,并且他被添加到右侧列表(和相反的操作)

这是我的HTML:

<div class="cont">
   <div  id="groupL" class="innDiv">
       <div id="1" class="aaaL">Value 1</div>
       <div id="2" class="aaaL">Value 2</div>
   </div>
   <div  id="groupR" class="innDiv">
       <div id="4" class="aaaR">Value 4</div>
       <div id="3" class="aaaR">Value 3</div>
   </div>
</div>
Run Code Online (Sandbox Code Playgroud)

这是javascript源码.

var clickLtoR  = function(n){
   _this = $('#'+n);
   $('#groupR').prepend('<div class="aaaR" id="'+n+'">'+_this.html()+'</div>');
  _this.remove();

}

var clickRtoL = function(n){
    _this = $('#'+n);
    $('#groupL').prepend('<div class="aaaL" id="'+n+'">'+_this.html()+'</div>');
    _this.remove();

}

$('.aaaL').click(function(){
    clickLtoR($(this).attr("id"));
});
$('.aaaR').click(function (){
    clickRtoL($(this).attr("id"));
});
Run Code Online (Sandbox Code Playgroud)

如果我点击"Value1"上的例子,我需要将此div移动到右侧.

它是有效的..但是如果我再次点击相同的元素,例如按照前面的"值1"示例,则没有任何关联的点击事件,也不会返回左侧列表.

如何解决这个问题并绑定点击"新元素"?

这里,JSFiddle的工作代码http://jsfiddle.net/uw446/1/

html javascript jquery bind onclick

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

样式表输入登录

我想编写CSS和HTML来从psd文件创建这个输入论坛在此输入图像描述

我有几个问题要问:

首先,我剪切了背景(没有其他图形元素).标题很简单.使用输入文本我发现很难:当用户点击矩形时,文本和图标会消失.

这是我的css代码:

input{
    background: url('input-bg.png') no-repeat;
    border: none;
    width: 303px;
    height: 36px;
}
#username{
    background: url('user-icon.png') no-repeat left;
}
#password{
    background: url('password-icon.png') no-repeat left;
}
Run Code Online (Sandbox Code Playgroud)

其中input-bg.png是以下图片: 在此输入图像描述

<div id="form-login"><img id="member-icon" src="member-icon.png" />
    <h2>Member login</h2>
    <ul>
        <li><input type="text" id="username" placeholder="User Name"/></li>
        <li><input type="password" id="password" placeholder="Password" /></li>
    </ul>
</div> 
Run Code Online (Sandbox Code Playgroud)

问题是没有显示小图标,因为输入文本的背景定义覆盖了它们.有一个简单的方法可以解决这个问题吗?

还有一种简单的方法可以重现右边的发光效果吗?我想用z-index的值比其他元素更高的效果,但是如果你点击窗体右边的按钮或输入文本,显然会出现问题.有什么建议吗?

html css html5 styling css3

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