有没有人建议检测一组字符串中的URL?
arrayOfStrings.forEach(function(string){
// detect URLs in strings and do something swell,
// like creating elements with links.
});
Run Code Online (Sandbox Code Playgroud)
更新:我使用这个正则表达式进行链接检测...显然几年后.
kLINK_DETECTION_REGEX = /(([a-z]+:\/\/)?(([a-z0-9\-]+\.)+([a-z]{2}|aero|arpa|biz|com|coop|edu|gov|info|int|jobs|mil|museum|name|nato|net|org|pro|travel|local|internal))(:[0-9]{1,5})?(\/[a-z0-9_\-\.~]+)*(\/([a-z0-9_\-\.]*)(\?[a-z0-9+_\-\.%=&]*)?)?(#[a-zA-Z0-9!$&'()*+.=-_~:@/?]*)?)(\s+|$)/gi
Run Code Online (Sandbox Code Playgroud)
完整的助手(可选的Handlebars支持)在要点#1654670.
我有一系列的电子邮件(它可能只是一封电子邮件,或100封电子邮件),我需要发送带有ajax请求的数组(我知道该怎么做),但我只能发送一个包含10个或更少的电子邮件.因此,如果有一个包含20个电子邮件的原始数组,我需要将它们分成2个数组,每个10个.或者如果原始数组中有15个电子邮件,那么1个数组为10,另一个数组为5.我正在使用jQuery,最好的方法是什么?
如何将HTML5显示<video>为网站的全屏背景?与此Flash网站演示类似...
http://activeden.net/item/full-screen-video-background-template-v2/full_screen_preview/29617
我正在打电话$("#foobar").css("line-height")并恢复"正常".如何将其转换为像素数量?CSS规范中是"正常"定义还是浏览器特定?
我正在尝试创建一个表来显示个人的BMI.
作为其中的一部分,我想,on:hover,for <tr> 和 <col>(或<colgroup>)也要突出显示,以便交叉更加明显.
由于该表将同时包含公制和英制测量,因此:悬停不必停在单元格(从任何方向),并且如果它从一个轴延伸到另一个轴,实际上将是奖励.我也使用XHTML 1.1 Strict doctype,如果这有所不同?
所以...一个例子(真正的桌子......更大),但这应该具有代表性:
<script>
tr:hover {background-color: #ffa; }
colgroup:hover,
col:hover {background-color: #ffa; }
</script>
Run Code Online (Sandbox Code Playgroud)
...
<table>
<col class="weight"></col><colgroup span="3"><col class="bmi"></col></colgroup>
<tr>
<th></th>
<th>50kg</th>
<th>55kg</th>
<th>60kg</th>
</tr>
<tr>
<td>160cm</td>
<td>20</td>
<td>21</td>
<td>23</td>
</tr>
<tr>
<td>165cm</td>
<td>18</td>
<td>20</td>
<td>22</td>
</tr>
<tr>
<td>170cm</td>
<td>17</td>
<td>19</td>
<td>21</td>
</tr>
</table>
Run Code Online (Sandbox Code Playgroud)
我问不可能,我需要去JQuery病房吗?
我有一个带有选择和几个文本输入的表单.我想要在更改选择时提交表单.使用以下方法可以正常工作:
onchange="this.form.submit()"
Run Code Online (Sandbox Code Playgroud)
但是,如果表单还包含提交按钮,则更改选择时表单不会提交.我猜是某种冲突.
我有什么选择?
我应该使用类似的东西
$(this.form).trigger("submit")
吗?
我正在使用以下列表:
<ol id="footnotes">
<a name="footnote1"><li></a>This is the first footnote...</li>
<a name="footnote2"><li></a>This is the second footnote...</li>
</ol>
Run Code Online (Sandbox Code Playgroud)
使用以下.css:
#footnotes {list-style-type: decimal;
list-style-color: #f90;
}
#footnotes li
{color: #000;
}
#footnotes a li,
#footnotes li a
{color: #f90;
}
Run Code Online (Sandbox Code Playgroud)
目的是让li/footer文本本身为黑色(#000),并将数字设置为orange(#f90).
我尝试过使用该list-style-color属性,但除了扰乱Web开发人员工具栏(在FF3.0.8/Ubuntu 8.04中)之外什么也没做,Midori同样不会显示橙色的数字(我以为我会在Webkit引擎中尝试它,以防万一...).
有任何想法吗?
编辑HTML(因为我记得标记不一定需要包含任何东西来起锚作用):
<ol id="footnotes">
<li><a name="footnote1"></a>This is the first footnote...</li>
<li><a name="footnote2"></a>This is the second footnote...</li>
</ol>
Run Code Online (Sandbox Code Playgroud)
回应那些建议使用<span>内部<li>...是的.发生了这种情况,虽然我感谢您的建议和所花费的时间,但我正在寻找(我是标准的,我是......;))更多...语义选项.
事实上,我想我可能会使用这种方法.虽然我接受了另一个与Pete Michaud不同的答案,因为它具有纯粹的信息性.谢谢!
我正在尝试创建一个BMI计算器.这应该允许人们使用公制或英制测量.
我意识到我可以使用隐藏的标签来解决我的问题,但这之前我已经打扰过我,所以我想我会问:我可以$_POST['variableName']用来查找提交的variableName字段值; 但是......我不知道,或者看看如何验证用于提交变量的表单.
我的代码如下(虽然我不确定它与问题严格相关):
<?php
$bmiSubmitted = $_POST['bmiSubmitted'];
if (isset($bmiSubmitted)) {
$height = $_POST['height'];
$weight = $_POST['weight'];
$bmi = floor($weight/($height*$height));
?>
<ul id="bmi">
<li>Weight (in kilograms) is: <span><?php echo "$weight"; ?></span></li>
<li>Height (in metres) is: <span><?php echo "$height"; ?></span></li>
<li>Body mass index (BMI) is: <span><?php echo "$bmi"; ?></span></li>
</ul>
<?php
}
else {
?>
<div id="formSelector">
<ul>
<li><a href="#metric">Metric</a></li>
<li><a href="#imperial">Imperial</a></li>
</ul>
<form name="met" id="metric" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" enctype="form/multipart">
<fieldset>
<label for="weight">Weight (<abbr title="Kilograms">kg</abbr>):</label> …Run Code Online (Sandbox Code Playgroud) jquery ×4
css ×3
javascript ×3
html ×2
xhtml ×2
arrays ×1
col ×1
forms ×1
html-table ×1
html5-video ×1
loops ×1
php ×1
regex ×1
select ×1
url ×1