ul嵌套在div层中的链接.鼠标指针越过.title,ul被示出.
问题:mouseout()适用于嵌套元素
mouseout() 是为了 div
<div>
<a class="title">Section A</a>
<ul>
<li><a href=''>link 1</a></li>
<li><a href=''>link 2</a></li>
<li><a href=''>link 3</a></li>
</ul>
</div>
Run Code Online (Sandbox Code Playgroud)
$('.title').mouseover(function() {
$('ul').slideDown();
})
$('div').mouseout(function(){
$('ul').slideUp();
});
Run Code Online (Sandbox Code Playgroud) 此函数返回用户已选择的文本并将其包装在标记中,在本例中为粗体标记.
function makeBold() {
var selection = window.getSelection();
var range = selection.getRangeAt(0);
var newNode = document.createElement("b");
range.surroundContents(newNode);
}
Run Code Online (Sandbox Code Playgroud)
现在,在我调用该函数后,将删除选择(突出显示的文本).如何返回该选择,或者如何在不丢失我的选择的情况下调用该函数?
编辑:我有一个函数,在标签之间包装一个字符串.我希望只有在字符串不包含任何标记时才应用此函数.
if string: "text" then "<b>text</b>";
else if string "<b>text</b>" then "text";
Run Code Online (Sandbox Code Playgroud)
我需要一个条件语句来检查给定的标签,并仅在找到标签时剥离标签.
例如. function stripTags(string, "span")
1-搜索给定的标签(在这种情况下为span)
2 - 如果找到,剥离标签
我想选择一个图像并为选择添加一个类名.使用window.getSelection.
function addClassName() {
var sel = window.getSelection();
//what goes here???
}
<input type='button' onclick='addClassName();' value='addClassName'/>
Run Code Online (Sandbox Code Playgroud) 当模式包含斜杠时,我收到未知修饰符错误
代码:
preg_replace('/$v/', $replacement, $string)
Run Code Online (Sandbox Code Playgroud)
var $v,有时是目录路径。
$v = folder/folder/file.ext
Run Code Online (Sandbox Code Playgroud)
如何处理 preg_replace 中的 $v ?
这是阵列
$array = array(
'list[P] = 1',
'list[A] = 1',
'list[F] = 2',
'list[B] = 1'
);
Run Code Online (Sandbox Code Playgroud)
这是我想要的输出
[0] => list[P] = 1
[1] => list[A] = 1
[2] => list[B] = 1
[3] => list[F] = 2
Run Code Online (Sandbox Code Playgroud)
通知list[P]仍然在顶部,因为它是第一个值为1.因此只有数字排序
数组中的项"引用"设置为$array['fruit'].但没有回报价值
$array = array(
'fruit'=>'apple',
'reference'=>$array['fruit']
);
Run Code Online (Sandbox Code Playgroud)
例: echo $array['reference']; //the word apple should be displayed
这个结果是如何实现的?
jquery ×4
javascript ×3
php ×3
arrays ×2
dom ×2
html ×2
execcommand ×1
key ×1
mouseevent ×1
mouseout ×1
mouseover ×1
nested ×1
regex ×1
sorting ×1