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