我必须'ul > li'获取所有列表项,但我只需要抓取包含已选中复选框的项目.
所以你可以直观地看到它,它看起来像这样:
<ul>
<li>
<input type="checkbox" checked="checked">
</li>
<li>
<input type="checkbox">
</li>
<li>
<input type="checkbox" checked="checked">
</li>
</ul>
Run Code Online (Sandbox Code Playgroud)
我想拉第1和第3项.
提前致谢.
所以我有
我有以下HTML
<table>
<tr>
<td><span></span></td>
<td><a><span></span></a></td>
<td><span></span><span><span/></td>
</tr>
<table/>
Run Code Online (Sandbox Code Playgroud)
我需要在每个td中选择跨度的第一个外观.我将从上面的HTML中删除3个跨度.
$('td span') 返回所有(4)跨度
$('td span:first-child') 也返回所有跨度
$('td span:first') 只返回
$('td > span') 只返回2个跨度.
我可以通过选择器或过滤器这样做吗?
我需要用什么来实现这一目标?
我正在使用jQuery 1.9.0,我试图on()在选择内部更改选项时触发该方法.它有效,live()但我认为它可能是一些我没有看到的简单.
这是我的HTML:
<select class="select_exercise">
<option class="option_exercise">Example 1</option>
<option class="option_exercise">Example 2</option>
</select>
Run Code Online (Sandbox Code Playgroud)
和我的剧本:
$("option.option_exercise").on("change","option.option_exercise",function()
{
alert("i am changing");
});
Run Code Online (Sandbox Code Playgroud)
这是小提琴
这是一个示例SVG图像,我需要将其背景颜色从当前的白色更改为透明(或黑色)。
到目前为止,我只能更改前景色。
<svg xmlns:sketch="http://www.bohemiancoding.com/sketch/ns" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" viewBox="5 5 90 90" version="1.1" x="0px" y="0px" id="svg14" sodipodi:docname="icon_link.svg" inkscape:version="0.92.1 r15371">
<metadata
id="metadata20">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
</cc:Work>
</rdf:RDF>
</metadata>
<defs
id="defs18" />
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="787"
inkscape:window-height="620"
id="namedview16"
showgrid="false"
inkscape:zoom="1.888"
inkscape:cx="50"
inkscape:cy="62.5"
inkscape:window-x="262"
inkscape:window-y="18"
inkscape:window-maximized="0"
inkscape:current-layer="svg14" />
<title
id="title2">1</title>
<desc
id="desc4">Created with Sketch.</desc>
<g
stroke="none"
stroke-width="1"
fill="none"
fill-rule="evenodd"
sketch:type="MSPage"
id="g8"
style="fill:#ff0000">
<path
d="M72.6749171,46.3009857 L27.3261728,46.3009857 L27.3261728,53.9297668 L72.6749171,53.9297668 L72.6749171,46.3009857 Z M84.6466542,29 …Run Code Online (Sandbox Code Playgroud)我有一个ASP.Net应用程序,它使用jQuery的AJAX POST方法来更新DOM.
除非用户在IE中手动刷新页面,否则一切正常.
如果他们进行了更改,则点击浏览器刷新按钮,然后再次执行这三个步骤,即使数据库已正确更新,也不显示他们刚刚输入的更新数据.
它显示原始数据.
他们必须完全关闭浏览器并重新打开它以查看更改.
这只发生在IE中.
FF和Chrome会在刷新时显示更改.
我在这里错过了什么?
JS
$(".deletable").live('click',function(){
$(this).parent().effect('explode', 500, function(){
$(this).parent().remove();
})
});
Run Code Online (Sandbox Code Playgroud)
HTML
<table>
<tr>
<td class='deletable'>hi</td>
</tr>
</table>
<ul>
<li>
<span class=deletable>hi</span>
</li>
</ul>
Run Code Online (Sandbox Code Playgroud)
我想删除tr以防万一td被点击并点击li案例span.
由于某种原因,这不起作用,而是整个ul/ table被删除.
为什么这样 ?
我实际上没有得到MouseEvent.Click事件和TouchEvent.Touch"事件之间的区别action script.
两者都在基于触摸的系统中提供相同的输出.
我想知道他们在处理用户事件方面有何不同.
我一直在使用JQuery,我在JFiddle上尝试了我的代码并且它运行良好但是当我在我的网站上执行它根本不起作用时,基本上我需要在我的用户列表中的列表项被点击时发送事件.
HTML
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://dl.dropbox.com/s/r5pzakk4ikvck3t/style.css?dl=1">
<script src="https://www.dropbox.com/s/2hdvqa4ma51m0pw/jquery-1.9.0.min.js?dl=1"></script>
<title>Chat</title>
</head>
<body>
<div id="userlist-container">
<div id="userlist-title">User List</div><br />
</div>
<div id="main-container">
<div id="messages">
</div>
</div>
<div id="control-container">
<input type="text" id="TxtMessage" placeholder="Message" onKeyPress="SendMsg(event)" style="text-align:center;" >
</div>
<div id="alert-container" hidden="hidden">
<div id="alert-main">
<span id="alert-content"></span>
</div>
</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
使用Javascript
$("#userlist-container > li").click(function(e) {
alert("TEST");
var username = "@" + this.html + " ";
$("TxtMessage").value(username);
$("TxtMessage").focus();
});
Run Code Online (Sandbox Code Playgroud)
编辑:
页面加载后,它连接到服务器并添加<li>lalala</li>到内部userlist-container.
我无法在提交时调用jQuery.不显示功能中的警报.
我想显示所有已选中复选框名称的警报.
这是我的代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js">
</script>
<script>
$(document).ready({
$("#roleManagement").submit(function() {
alert("hi");
var selected = new Array();
$('#checkboxes input:checked').each(function() {
selected.push($(this).attr('name'));
});
$.each(selected, function(key, value) {
alert(key + ": " + value);
});
});
</script>
<body>
<form method="post" id="roleManagement">Role Id
<input type="text" name="roll_id" />
<br>Role Name
<input type="text" name="roll_name" />
<br>Role Description
<textarea name="roll_desc"></textarea>
<br>
<br>
<br>
<div id="checkboxes">Screen1
<br>tab1
<br>
<input type="checkbox" …Run Code Online (Sandbox Code Playgroud) 我想在UL上的香草javascript中设置一个click事件侦听器,然后在其中单击,我想让该元素被单击,检查它是否为LI,如果不是-向上运行parentNode直到达到LI,如果达到-如果没有,则获取-停止在UL。
Jsfiddle- https: //jsfiddle.net/urbbsu0t/4/
我尝试了许多方法并阅读了几篇文章,但是当没有嵌套元素时(例如,如果我在LI内只有一个元素),我发现的所有内容都会起作用。但是如果我有很多孩子,我该如何比较?
这是一个LI元素的例子
<li class="service">
<div class="service-body">
<h1>Title goes here</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Sunt dicta
laborum, excepturi tenetur vero cum!</p>
<button>button goes here</button>
</div>
</li>
Run Code Online (Sandbox Code Playgroud)
<li class="service">
<div class="service-body">
<h1>Title goes here</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Sunt dicta
laborum, excepturi tenetur vero cum!</p>
<button>button goes here</button>
</div>
</li>
Run Code Online (Sandbox Code Playgroud)
const services = document.querySelector('.services');
services.addEventListener('click', function(e) {
})Run Code Online (Sandbox Code Playgroud)
.services {
display: flex;
justify-content: space-between;
}
.service {flex 1 30%; max-width: …Run Code Online (Sandbox Code Playgroud)