많은 하위 항목이 포함 된 html 블록이 있습니다.요소의 모든 하위 항목을 순환하여 해당 속성을 가져옵니다.
<div id="selectedId">
<div class=".."><a class=".."></a>
<button style=".."></button>
</div>
<div id="otherId">
<table></table>
</div>
</div>
부모를 선택하려면 jquery를 사용하고 있습니다. 그런 다음 모든 자손을 반복하고 클래스 또는 innerHtml과 같은 다양한 속성에 액세스하려고합니다. 나는 그들의 속성에 액세스 할 수없는 것 같습니다.
function rewriteCategoryName(oldCategoryName, newCategoryName)
{
// get div parent
var parentDiv = $("#selectedId");
parentDiv.find('*').each(function(el,key) {
alert(el+" --");
el.each(function(el,key) {
// i get just numbers here, and undefined on everything
// i try to access
});
});
}
아이디어가 있으십니까? 여기서 내가 뭘 잘못하고 있니? 제가 누락 된 개념이 있습니까?
http://stackoverflow.com/questions/14645806/get-all-attributes-of-an-element-using-jquery –
'$ ('. oldClassName ')은 무엇입니까? removeClass ('oldClassName '). addClass ('newClassName ');' – jantimon
템플릿을 사용해야 할 수도 있습니다. http://handlebarsjs.com/ – jantimon