1
$(document).ready(function(){
$(".EditBusinessName").hide();
$(".editBtn a").click(function() {
$(this).parent().parent('.myBusinessEdit').children('.EditBusinessName').show();
$(this).hide();
});
$(".EditBusinessName a").click(function() {
$(this).parent().parent(".EditBusinessName").hide();
$(this).parent().parent().parent().children(".editBtn").children("a").show();
});
});
我怎么能简化上述代码的代码,而无需使用parent()
和children()
选择? div
类myBusinessEdit
将是每个部分的通用类。简化无父母和孩子选择
http://plnkr.co/edit/xgP49K51urBvZQlyLGxQ?p=preview
为什么你不想使用'父()'或'儿童()'? '最接近()'和'find()'也可以工作,这取决于你的要求。 –
一旦我在CMS中使用此静态代码,将会有额外的Div。 – Anoops