我有以下内容:FIDDLE
占位符工作正常,花花公子,直到你键入一些东西,ctrl+ A,和delete.如果这样做,占位符将消失,并且不会再次显示.
怎么了?我怎样才能拥有一个可满足的div的占位符?
HTML:
<div class="test" placeholder="Type something..." contenteditable="true"></div>
Run Code Online (Sandbox Code Playgroud)
.test {
width: 500px;
height: 70px;
background: #f5f5f5;
border: 1px solid #ddd;
padding: 5px;
}
.test[placeholder]:empty:before {
content: attr(placeholder);
color: #555;
}
Run Code Online (Sandbox Code Playgroud)
我有以下内容:http://jsfiddle.net/4QF4C/14/
为什么红色方块在动画期间隐藏在黑线后面,然后在完成后显示?我怎样才能解决这个问题?
HTML:
<div class="container">
<div class="content">
<div class="box-static">
This is a static box that isn't effected by JQuery.
<div class="dot"></div>
</div>
<div class="box">
This is just some text.
<div class="dot"></div>
</div>
<a href="#">Click Me!</a>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
CSS:
.container {
width: 900px;
margin-left: auto;
margin-right: auto;
}
.content {
width: 550px;
float: right;
border-left: 5px solid black;
position: relative;
height: 250px;
}
.box-static {
width: 500px;
position: relative;
padding: 12px;
margin: 10px 0 0 17px;
background-color: lightgrey; …Run Code Online (Sandbox Code Playgroud) 我正在使用xampp,我正在尝试模拟慢速连接,这样我就可以测试一些我用图像上传和进度条完成的事情.
我尝试过使用Fiddler和mod_bw,这两个都不适合我(mod_bw有点过时了,我甚至不确定它是否可以工作).
有谁知道如何模拟localhost上的慢速连接?
我正在尝试遵循此答案,但不是像他在 jsfiddle 中那样使用按钮,而是尝试使用列表项:
http://jsfiddle.net/hqvDT/108/
看起来它应该可以工作,但是当我尝试选择一些文本然后按B(粗体)时,它实际上并没有将文本加粗。
怎么了?
HTML:
<div id="myarea" contenteditable="true"></div>
<ul>
<li onclick="MakeBold();">B</li>
<li><i>I</i></li>
</ul>
Run Code Online (Sandbox Code Playgroud)
CSS:
#myarea {
border:1px solid #000;
padding:5px;
height:150px;
width:400px;
overflow:scroll;
}
ul {
list-style: none;
}
ul li {
width: 35px;
height: 35px;
border: 1px solid #ccc;
text-align: center;
line-height: 32px;
font-size: 14px;
color: #999;
cursor: pointer;
display: inline-block;
margin-right: -5px;
font-weight: bold;
font-size: 18px;
}
ul li:hover {
color: black;
}
Run Code Online (Sandbox Code Playgroud)
JS:
function MakeBold() {
document.execCommand('bold', null, false);
}
Run Code Online (Sandbox Code Playgroud) 我已经做了一些关于在PHP中验证URL的研究,发现StackOverflow上有很多不同的答案,有些比其他答案更好,有些已经很老了,过时了.
我有一个用户可以输入网站网址的字段.用户应该能够以任何形式输入URL,例如:
example.com
www.example.com
http://example.com
http://www.example.com
https://example.com
https://www.example.com
Run Code Online (Sandbox Code Playgroud)
PHP附带了一个验证URL的功能,但是,如果URL没有,它会将URL标记为无效http://.
我如何验证任何类型的URL,无论是否有,http://或https://确保URL有效?
谢谢.
我有一个令人满意的div作为textarea:
<div class="post" placeholder="Write a comment..." contenteditable="true"></div>
Run Code Online (Sandbox Code Playgroud)
如何通过JS/JQuery清空div,以便清除所有值?
我试过$(".post").html("");但它不能正常工作.
请帮忙.
我有一个像这样的满足的div:
<form>
<div name="new_post" class="post" contenteditable="true"></div>
<button type="submit">Submit</button>
</form>
Run Code Online (Sandbox Code Playgroud)
contenteditable div允许使用粗体和斜体标签,但没有其他标签.
我的问题是,如果用户键入类似的东西Hello there <u>world</u>!,它将保存在数据库中Hello there.它似乎删除标签后的所有内容,我不知道为什么.
我正在使用AJAX和PHP来处理帖子,所以这是代码的其余部分.
阿贾克斯:
$(document).ready(function() {
$(document).on("submit", "form", function(event) {
event.preventDefault();
alert($('.post').html()); // added this to debug it. This prints "Hello there <u>world</u>!"
$.ajax({
url: 'php/post.php',
type: 'POST',
dataType: 'json',
data: $(this).serialize() + "&post_field=" + $('.post').html(),
success: function(data) {
alert(data.message);
}
});
});
});
Run Code Online (Sandbox Code Playgroud)
PHP:
<?php
$post = $_POST["post_field"];
// query to insert post into database goes …Run Code Online (Sandbox Code Playgroud) 我有以下函数来计算用户在textarea中输入的字符数:
$("textarea").keyup(function() {
var max = 500;
var length = $(this).val().length;
var char = max - length;
if (length > max) {
$(this).parent().find('.counter span').html('<div class="text-error">' + char + '</div>');
} else {
$(this).parent().find('.counter span').text(char);
}
});
Run Code Online (Sandbox Code Playgroud)
如果我向页面引入新的DOM,则上述函数不适用于新引入的textarea.如何使其与新DOM一起使用?
谢谢.