<li>通过点击它来设置类.现在,嵌套的element(<button>)不会从它的父级中删除该类.
提前致谢.
$(document).ready(function() {
$('.pickOne li').click(function() {
$(this).addClass('active');
});
$('.settingsCancelBtn').click(function() {
$(this).parent().parent().removeClass('active');
});
});
Run Code Online (Sandbox Code Playgroud)
HTML就像这样:
<div class="fromCamp pickOne four">
<ul class="four">
<li class="first bus"><a href="#" alt="By Bus"></a>
<div>
<p class="cmInfo">Arrive between 9 AM and 11 AM. Read these <a href="#">additional instructions</a>. <a href="#">Driving Directions</a></p>
<p><a href="#">Tilefishes</a></p>
<p><a href="#">Bluefishes</a></p>
<p><a href="#">Tigerfishes</a></p>
<button class="cmCancelDeleteButton settingsCancelBtn" type="button">Cancel</button>
<button class="cmGoButton settingsSaveBtn" type="button">Save</button>
</div>
</li>
<li class="second car"><a href="#" alt="By Car"></a>
<div>
<p><a href="#">Remoras</a></p>
<p><a href="#">Tilefishes</a></p>
<p><a href="#">Bluefishes</a></p>
<p><a href="#">Tigerfishes</a></p>
<button class="cmCancelDeleteButton …Run Code Online (Sandbox Code Playgroud) 如果我需要从flex项目中的子项调用父应用程序中的特定函数,那么最佳实践是什么?是从子节点调度自定义事件并让侦听器调用该函数吗?或者直接使用FlexGlobals.topLevelApplication调用该函数?
基于接受的答案的最终工作代码
$('#photo-upload, #photo-upload .close').click(function(){
$('#photo-upload').removeClass('show');
});
$('#upload-button').click(function(){
$('#photo-upload').addClass('show');
});
$('#form-window').click(function(e){
e.stopPropagation();
});
Run Code Online (Sandbox Code Playgroud)
原始问题
我有一个带关闭按钮的模式窗口。该窗口由链接触发a#upload-button。#photo-upload是一个 100% 高度 + 宽度的固定 div。#form-window是一个 200 像素 x 200 像素的框,在其内部水平和垂直居中#photo-upload
<div id="photo-upload">
<div id="form-window">
<!-- Content -->
<a class="close"></a>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
关闭按钮的位置绝对位于右上角。我想设置一个点击功能,以便在模态窗口外点击关闭窗口,并且点击关闭按钮关闭窗口。但是这样点击窗口本身不会关闭窗口。
我目前的代码是:
$('#photo-upload').click(function(e){
if(!$(e.target).is('#form-window')){
return false;
} else {
$(this).removeClass('show');
}
});
$('#form-window').live("click",function(e){
if(!$(e.target).is('a.close')){
e.stopPropagation();
}
});
$('#upload-button').live("click", function(){
$('#photo-upload').addClass('show');
});
$('#photo-upload .close').live("click", function(){
$('#photo-upload').removeClass('show');
});
Run Code Online (Sandbox Code Playgroud)
使用上面的代码,当我单击这些元素中的任何一个时没有任何反应,并且无法关闭 div。我究竟做错了什么?
如何在父元素上使用 stopPropagation() 但排除子元素(在我的情况下,a.close)。
问题更新:
我想在C++中执行以下操作:
struct Param {
public:
int len;
int in1;
float in2;
};
Param params;
class Element {
private:
int value1;
float value2;
public:
Element();
Element(int n) {value1 = n; value2 = 0;}
Element(int n1, float n2) {value1 = n1; value2 = n2;}
}
class Parent {
private:
class Element elem;
vector<Element> elemVec;
public:
Parent();
Parent(int n);
}
Run Code Online (Sandbox Code Playgroud)
我希望写下面的构造,使得在调用Parent构造函数,类元素的非默认的构造函数elem和elemVec也被调用.我已经发现elem需要调用的构造函数如下:
Parent::Parent(int n) : elem(n) {
}
Run Code Online (Sandbox Code Playgroud)
我现在该如何构建中的每个元素elemVec向量,从而Element(int, float)构造函数被调用每个向量元素与int …
经过几个小时的设计战,我来找你一只手.我正在建立一个夜总会的网站,你可以看到.

我无法将居中区域(以黄色为边界)拉伸到页脚开始的页面底部(页脚是绿色顶部边框div).发生这种情况是因为内容不足以填补其余的高度.
这是我的CSS
html, body{
height: 100%;
margin: 0 auto;
}
#container{
height: auto !important;
height: 100%;
margin: 0 auto -50px; /* as #footer height */
min-height: 100%;
text-align: center;
border: 5px solid blue;
}
#centered-container{
width: 950px;
margin: 0 auto;
text-align: left;
border: 5px solid yellow;
}
#body-container{
border: 5px solid red;
}
#footer, .footer{
height: 50px;
}
#footer{
text-align: center;
border-top: 5px solid green;
}
Run Code Online (Sandbox Code Playgroud)
这是我的HTML标记
<body>
<div id="container"> <!-- BLUE BORDER -->
<div id="centered-container"> <!-- YELLOW BORDER …Run Code Online (Sandbox Code Playgroud) 我有一个类(例如Foo)它覆盖 ToString 方法来打印它的内部状态。这个类有一个集合Foo- 它是子元素。孩子也可以生孩子等等。
我正在寻找在 ToString() 中实现的解决方案,它会自动缩进子元素,例如:
Parent Foo
Child1 Foo
Child1.1 Foo
Child2 Foo
Child2.1 Foo
Child2.2 Foo
Run Code Online (Sandbox Code Playgroud) 我想确定父进程调用了哪些进程(或者可能得到一个“堆栈”或分层引起的进程树)。
不幸的是,由于进程终止太快,因此很难“动态”确定 PID、GPID 和 PPID。可能这些信息可以在系统日志中找到?
我使用 RHEL 6.4。
非常感谢。
如何使父进程设置为我的应用程序的控件“弹出”我的应用程序并成为顶级窗口?
我试过使用SetParent(WindowHandle, null);但 IntPtr 它说它是一个不可为空的类型。
现成的GetAll和Get方法CrudAppService不包括子实体。
是否可以修改其行为?
GetAllIncluding如果所包含的实体具有到父级的导航属性,则存在一些问题;它属于一种循环依赖关系。是否有任何Attribute技巧可以将导航属性排除在序列化之外?该[NonSerialized]属性似乎不适用于导航属性。
PostAppService:
public class PostAppService : CrudAppService<Post, PostDto>, IPostAppService
{
IRepository<Post> _repository = null;
public PostAppService(IRepository<Post> repository) : base(repository)
{
_repository = repository;
}
protected override IQueryable<Post> CreateFilteredQuery(PagedAndSortedResultRequestDto input)
{
return _repository.GetAllIncluding(p => p.Items);
}
}
Run Code Online (Sandbox Code Playgroud)
PostDto:
[AutoMap(typeof(Post))]
public class PostDto : EntityDto
{
public ICollection<Item> Items { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
职位实体:
[Table("AbpPosts")]
public class Post : FullAuditedEntity<int,User>
{
public virtual ICollection<Item> …Run Code Online (Sandbox Code Playgroud) c# parent-child entity-framework-core asp.net-core aspnetboilerplate
我具有以下BEM设置:
.mytable {
font-size: 16px;
margin: 30px 0;
&--standard {
border: 1px solid red;
&__row {
border: 1px solid blue;
}
}
Run Code Online (Sandbox Code Playgroud)
我想做的是仅将行样式应用于修改后的表类。
输出以下内容
.mytable--standard__row {
border: 1px solid blue;
}
Run Code Online (Sandbox Code Playgroud)
这显然不是我想要达到的目标。
有没有一个整洁/标准的方法来解决这个问题?
parent-child ×10
c# ×2
jquery ×2
process ×2
apache-flex ×1
asp.net-core ×1
bem ×1
c++ ×1
click ×1
collections ×1
constructor ×1
css ×1
html ×1
linux ×1
pinvoke ×1
removeclass ×1
sass ×1
tostring ×1
window ×1