小编Sar*_*nga的帖子

如何在标签文本更改时触发事件

我正在尝试在标签文本更改时触发一个函数.这是我的代码

$("#frameItemCode").change(function (e) {
    alert("Changed");
});
Run Code Online (Sandbox Code Playgroud)

#frameItemCode是我的标签ID,但事件没有触发.我之前尝试了一些例子,但他们没有帮助过我.这是我的HTML

<div class="input-group">
  <span class="input-group-addon" @*style="width: 120px;"*@>Item Group</span>
  <label class="input-group-addon" @*style="width: 120px;"*@ id="frameGroupCode"></label>
  <input class="form-control" type="text" id="frameGroupName" style="">
</div>
Run Code Online (Sandbox Code Playgroud)

html javascript jquery

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

使用javascript调整图像大小

我正在使用javascript函数输入图像.

这是我的HTML:

<input type="file" name="filUpload" id="filUpload" onclick="" onchange="showimagepreview(this)">
<br />
<div id="before">
<img id="imgprvw" alt="" class="img-thumbnail" style="width: 250px; height: 250px;" />
Run Code Online (Sandbox Code Playgroud)

这是我的JavaScript:

function showimagepreview(input) { //image preview after select image
  if (input.files && input.files[0]) {
    var filerdr = new FileReader();
    filerdr.onload = function(e) {
      url = e.target.result;
      image = url;
      $('#imgprvw').attr('src', url);
      //console.log(url);

      //$('#imgprvw').attr('src', e.target.result);
      //url = e.target.result;
      //$("#imgpath").val(url);
    }
    filerdr.readAsDataURL(input.files[0]);
  }
}
Run Code Online (Sandbox Code Playgroud)

此代码将图像转换为咬合数组,我需要使用该咬合数组调整图像大小.有没有可行的方法来做到这一点.

我将该二进制数组传递给Web服务.我的图像尺寸太高,需要很长时间,这就是我需要转换的原因.

html javascript

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

限制html文本框长度

我有HTML textbox,我会阻止使用正则表达式添加字符.这是我的代码:

$("#CardNo").keypress(function (e) {

    if (e.keyCode == "13") {
        $("#CardAmount").focus();
    }
    else {
        $(this).val($(this).val().replace(/[^0-9]/g, ''));
        if ((event.which < 48 || event.which > 57)) {
            event.preventDefault();
        }
    }
});
Run Code Online (Sandbox Code Playgroud)

我需要添加另一个用于限制textbox长度的正则表达式部分,6我该怎么做?

html javascript

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

标签 统计

html ×3

javascript ×3

jquery ×1