可能重复:
如何获取<textarea>中的行数?
我有一个textarea和我7 lines在其中写的只是2 new line character如下,想象下面的代码框是一个textarea,只有两次输入键被按下.
A text box, text field or text entry box is a kind of widget used when building
a graphical user interface (GUI). A text box purpose is to allow the user to
input text information to be used by the program.
User-interface guidelines recommend a single-line text box when only one line of
input is required, and a multi-line text box only if more than …Run Code Online (Sandbox Code Playgroud) 在手机上我无法查看这两个按钮,因为它们相距太远.我想在你选择文件后这样做,'选择文件'按钮将被上传按钮取代.这可能吗.我该怎么办?
http://goawaymom.com/buttons.png
我的HTML -
<form method="post" action="" enctype="multipart/form-data" name="form1">
<input name="file" type="file"class="box"/>
<input type="submit" id="mybut" value="Upload" name="Submit"/>
</form>
Run Code Online (Sandbox Code Playgroud)
- 注意我不在乎将它们放在单独的行上或使字体变小等
我有一个看起来像这样的无序列表
HTML
<div id="pop">
<ul>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
<li>Item 4</li>
<li>Item 5</li>
<li>Item 6</li>
<li>Item 7</li>
</ul>
</div>
<div id="info-1></div>
<div id="info-2></div>
Run Code Online (Sandbox Code Playgroud)
当您将鼠标悬停在其中一个项目上时,会显示一个窗口,其中包含有关该项目的一些信息.我已经为一个项目解决了这个问题,现在我想知道如何在整个列表中完成这项工作.
我最初的想法是为每个项目创建一个脚本......但考虑到js的功能,这似乎有点厚.
使用Javascript
$(function(){
$('pop a').hover(function(){
$('#info-1').show();
},function(){
$('#info-1').hide();
});
});
Run Code Online (Sandbox Code Playgroud)
所以我的问题当然是,如何让这个脚本适用于所有项目.
我想在javascript中使用正则表达式格式化网址...
输入:http://www.google.com或https://www.yahoo.com
我正在使用这个正则表达式捕获 /(http\:\/\/|https\:\/\/){0,1}(.*)/
所以$1要说的是它http还是https和$2休息的url ...
现在,我想替换http用1,并https用2使输出应该象下面这样:
1www.google.com 和 2www.yahoo.com
我使用下面的代码,但它不起作用......
var url = "http://www.microsoft.com";
url.replace(/(http\:\/\/|https\:\/\/){0,1}(.*)/, ("$1"=="http://"?"1":"2")+"$2");
// output: 2www.microsoft.com
url.replace(/(http\:\/\/|https\:\/\/){0,1}(.*)/, ("$1"=="http://")+"$2");
// output: falsewww.microsoft.com
Run Code Online (Sandbox Code Playgroud)
有谁知道怎么做......?谢谢...
我在一个项目中,大部分时间我不得不进口工作computed style的html divs...所以我试图创建一个自定义prototype下,Object使我的一点不错,简单和更短......这里是为我工作的代码...
Object.prototype.css=function(){
return window.getComputedStyle(this);
}
Run Code Online (Sandbox Code Playgroud)
当var a是node的html div,我需要height的是div,我必须使用prototype像下面...
a.css().height;
Run Code Online (Sandbox Code Playgroud)
现在的问题是......我怎么能修改我function使用的prototype...
a.css.height; // css insead of css()
Run Code Online (Sandbox Code Playgroud)
没有jQuery请...
使用prototype方法我们可以创建新方法......比如......
Object.prototype.newMethod=function(){
// do something
}
Run Code Online (Sandbox Code Playgroud)
这里我newMethod用匿名函数定义...现在如果我想使用这个方法,我必须使用它:<object>.newMethod();
但现在我想创建一个我可以使用的新方法:<object>.newMethod;......没有括号......我怎么能这样做......?
请不要使用任何jQuery ...
javascript ×6
html ×3
button ×1
css ×1
function ×1
jquery ×1
line-count ×1
prototype ×1
regex ×1
textarea ×1